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)
 
   95                        if($archive[
'archive_type'] == $this->ARCHIVE_XML)
 
   99                        if($this->course_obj->getArchiveType() != $this->course_obj->ARCHIVE_DOWNLOAD and
 
  100                                $archive[
'archive_type'] == $this->ARCHIVE_PDF)
 
  104                        $public_archives[$id] = $archive;
 
  107                return $public_archives ? $public_archives : array();
 
  116                return $this->archive_type ? $this->archive_type : $this->ARCHIVE_XML;
 
  121                $this->archive_date = $a_date;
 
  125                return $this->archive_date ? $this->archive_date : time();
 
  130                $this->archive_size = $a_size;
 
  138                $this->archive_name = $a_name;
 
  146                $this->archive_lang = $a_lang_code;
 
  161                        return $this->course_files_obj->getArchiveDirectory().
'/'.$archive[
'archive_name'].
'.zip';      
 
  165                        return $this->course_files_obj->getArchiveDirectory().
'/'.$archive[
'archive_name'];     
 
  177                $this->
setType($this->ARCHIVE_XML);
 
  178                $this->
setName(time().
'__'.$this->
ilias->getSetting(
'inst_id').
'__crs_'.$this->course_obj->getId());
 
  183                $this->course_files_obj->addArchiveSubDirectory($this->
getName());
 
  188                $this->course_xml_writer->start();
 
  189                $this->course_files_obj->writeArchiveFile($this->course_xml_writer->getXML(),$this->getName().
'/'.$this->getName().
'.xml');
 
  194                $this->course_files_obj->addArchiveSubDirectory($this->
getName().
'/objects');
 
  196                $this->copied_files = array();
 
  197                $this->
__addZipFiles($this->course_obj->getRefId(), $a_selection);
 
  200                include_once(
"./Services/Export/classes/class.ilExport.php");
 
  202                        $this->getName().
'/index.html', $this->course_obj->getId(),$this->copied_files);
 
  205                $this->
setSize($this->course_files_obj->zipArchive($this->getName(),$this->getName().
'.zip'));
 
  216                $this->
setType($this->ARCHIVE_HTML);
 
  218                $this->
setName($this->
getDate().
'__'.$this->
ilias->getSetting(
'inst_id').
'__crs_'.$this->course_obj->getId());
 
  222                $this->course_files_obj->addArchiveSubDirectory($this->
getName());
 
  225                $this->course_files_obj->addArchiveSubDirectory($this->
getName().
'/objects');
 
  232                $this->course_files_obj->createArchiveOnlineVersion($this->
getName());
 
  235                $this->
setSize($this->course_files_obj->zipArchive($this->getName(),$this->getName().
'.zip'));
 
  248                $next_id = 
$ilDB->nextId(
'crs_archives');
 
  249                $query = 
"INSERT INTO crs_archives (archive_id,course_id,archive_name,archive_type,archive_date,archive_size,archive_lang) ".
 
  251                        $ilDB->quote($next_id,
'integer').
", ".
 
  252                        $ilDB->quote($this->course_obj->getId(),
'integer').
",".
 
  254                        $ilDB->quote($this->
getType(),
'integer').
", ".
 
  255                        $ilDB->quote($this->
getDate(),
'integer').
",".
 
  256                        $ilDB->quote($this->
getSize(),
'integer').
",".
 
  265        function delete($a_id)
 
  272                $this->course_files_obj->deleteArchive($this->archives[$a_id][
"archive_name"]);
 
  274                $query = 
"DELETE FROM crs_archives ".
 
  275                        "WHERE course_id = ".$ilDB->quote($this->course_obj->getId(),
'integer').
" ".
 
  276                        "AND archive_id = ".$ilDB->quote($a_id,
'integer').
" ";
 
  293                if(!is_object($this->course_files_obj))
 
  295                        include_once(
'Modules/Course/classes/class.ilFSStorageCourse.php');
 
  303                if(!is_object($this->course_xml_writer))
 
  305                        include_once 
"./Modules/Course/classes/class.ilCourseXMLWriter.php";
 
  320                $this->course_obj->initCourseItemObject();
 
  321                $this->course_obj->items_obj->setParentId($a_parent_id);
 
  323                foreach($this->course_obj->items_obj->getAllItems() as $item)
 
  329                        $action = $a_selection[$item[
'child']];
 
  330                        if ($a_selection == 
"")
 
  335                        if  ($action == 
"omit")
 
  340                        if ($action == 
"create")
 
  342                                $abs_file_name = $tmp_obj->getXMLZip();
 
  346                                include_once(
"./Services/Export/classes/class.ilExport.php");
 
  349                                if (!@is_file($abs_file_name))
 
  356                        if ($abs_file_name != 
"")
 
  359                                $new_name = basename($abs_file_name);
 
  360                                $this->course_files_obj->copyFile($abs_file_name,$this->course_files_obj->getArchiveDirectory().
'/'.
 
  361                                                                                                                                $this->getName().
'/'.$new_name);
 
  362                                if (is_file($this->course_files_obj->getArchiveDirectory().
'/'.
 
  363                                        $this->getName().
'/'.$new_name))
 
  365                                        $this->copied_files[] = array(
"title" => $item[
'title'],
 
  366                                                "file" => $new_name, 
"type" => $item[
'type']);
 
  378                $this->course_obj->initCourseItemObject();
 
  379                $this->course_obj->items_obj->setParentId($a_parent_id);
 
  381                foreach($this->course_obj->items_obj->getAllItems() as $item)
 
  387                        if($abs_dir_name = $tmp_obj->getHTMLDirectory())
 
  389                                $new_name = 
'il_'.$this->ilias->getSetting(
'inst_id').
'_'.$tmp_obj->getType().
'_'.$item[
'obj_id'];
 
  391                                $this->course_files_obj->addDirectory($this->
getName().
'/objects/'.$new_name);
 
  392                                $this->course_files_obj->rCopy($abs_dir_name,$this->
getName().
'/objects/'.$new_name);
 
  395                                $this->html_files[
"$item[obj_id]"] = 
"objects/".$new_name.
"/index.html";
 
  411                        $lng->loadLanguageModule(
'crs');
 
  418                $tmp_tpl = 
new ilTemplate(
"tpl.crs_export.html",
true,
true,
'Modules/Course');
 
  420                $this->course_files_obj->copyFile(
$tpl->tplPath.
'/'.
$ilias->account->prefs[
"style"].
'.css',
 
  421                                                                          $this->course_files_obj->getArchiveDirectory().
'/'.$this->getName().
'/default.css');
 
  423                $tmp_tpl->setVariable(
'TITLE',
$lng->txt(
'crs_export'));
 
  424                $tmp_tpl->setVariable(
"CRS_STRUCTURE",
$lng->txt(
'crs_structure'));
 
  427                $tmp_tpl->setVariable(
"DETAILS_TITLE",
$lng->txt(
"crs_details"));
 
  430                $tmp_tpl->setVariable(
"TXT_SYLLABUS",
$lng->txt(
"crs_syllabus"));
 
  431                $tmp_tpl->setVariable(
"TXT_CONTACT",
$lng->txt(
"crs_contact"));
 
  432                $tmp_tpl->setVariable(
"TXT_CONTACT_NAME",
$lng->txt(
"crs_contact_name"));
 
  433                $tmp_tpl->setVariable(
"TXT_CONTACT_RESPONSIBILITY",
$lng->txt(
"crs_contact_responsibility"));
 
  434                $tmp_tpl->setVariable(
"TXT_CONTACT_EMAIL",
$lng->txt(
"crs_contact_email"));
 
  435                $tmp_tpl->setVariable(
"TXT_CONTACT_PHONE",
$lng->txt(
"crs_contact_phone"));
 
  436                $tmp_tpl->setVariable(
"TXT_CONTACT_CONSULTATION",
$lng->txt(
"crs_contact_consultation"));
 
  437                $tmp_tpl->setVariable(
"TXT_DATES",
$lng->txt(
"crs_dates"));
 
  438                $tmp_tpl->setVariable(
"TXT_ACTIVATION",
$lng->txt(
"crs_activation"));
 
  439                $tmp_tpl->setVariable(
"TXT_SUBSCRIPTION",
$lng->txt(
"crs_subscription"));
 
  440                $tmp_tpl->setVariable(
"TXT_ARCHIVE",
$lng->txt(
"crs_archive"));
 
  443                $tmp_tpl->setVariable(
"SYLLABUS",nl2br($this->course_obj->getSyllabus() ? 
 
  444                                                                                                 $this->course_obj->getSyllabus() : 
 
  445                                                                                                 $lng->txt(
"crs_not_available")));
 
  447                $tmp_tpl->setVariable(
"CONTACT_NAME",$this->course_obj->getContactName() ? 
 
  448                                                                $this->course_obj->getContactName() : 
 
  449                                                                $lng->txt(
"crs_not_available"));
 
  450                $tmp_tpl->setVariable(
"CONTACT_RESPONSIBILITY",$this->course_obj->getContactResponsibility() ? 
 
  451                                                                $this->course_obj->getContactResponsibility() : 
 
  452                                                                $lng->txt(
"crs_not_available"));
 
  453                $tmp_tpl->setVariable(
"CONTACT_PHONE",$this->course_obj->getContactPhone() ? 
 
  454                                                                $this->course_obj->getContactPhone() : 
 
  455                                                                $lng->txt(
"crs_not_available"));
 
  456                $tmp_tpl->setVariable(
"CONTACT_CONSULTATION",nl2br($this->course_obj->getContactConsultation() ? 
 
  457                                                                $this->course_obj->getContactConsultation() : 
 
  458                                                                $lng->txt(
"crs_not_available")));
 
  459                if($this->course_obj->getContactEmail())
 
  461                        $tmp_tpl->setCurrentBlock(
"email_link");
 
  462                        #$tmp_tpl->setVariable("EMAIL_LINK","ilias.php?baseClass=ilMailGUI&type=new&rcp_to=".$this->course_obj->getContactEmail());
 
  463                        $tmp_tpl->setVariable(
"CONTACT_EMAIL",$this->course_obj->getContactEmail());
 
  464                        $tmp_tpl->parseCurrentBlock();
 
  468                        $tmp_tpl->setCurrentBlock(
"no_mail");
 
  469                        $tmp_tpl->setVariable(
"NO_CONTACT_EMAIL",$this->course_obj->getContactEmail());
 
  470                        $tmp_tpl->parseCurrentBlock();
 
  472                if($this->course_obj->getActivationUnlimitedStatus())
 
  474                        $tmp_tpl->setVariable(
"ACTIVATION",
$lng->txt(
'crs_unlimited'));
 
  478                        $str = 
$lng->txt(
"crs_from").
" ".strftime(
"%Y-%m-%d %R",$this->course_obj->getActivationStart()).
" ".
 
  479                                $lng->txt(
"crs_to").
" ".strftime(
"%Y-%m-%d %R",$this->course_obj->getActivationEnd());
 
  480                        $tmp_tpl->setVariable(
"ACTIVATION",$str);
 
  482                if($this->course_obj->getSubscriptionUnlimitedStatus())
 
  484                        $tmp_tpl->setVariable(
"SUBSCRIPTION",
$lng->txt(
'crs_unlimited'));
 
  488                        $str = 
$lng->txt(
"crs_from").
" ".strftime(
"%Y-%m-%d %R",$this->course_obj->getSubscriptionStart()).
" ".
 
  489                                $lng->txt(
"crs_to").
" ".strftime(
"%Y-%m-%d %R",$this->course_obj->getSubscriptionEnd());
 
  490                        $tmp_tpl->setVariable(
"SUBSCRIPTION",$str);
 
  492                if($this->course_obj->getArchiveType() == $this->course_obj->ARCHIVE_DISABLED)
 
  494                        $tmp_tpl->setVariable(
"ARCHIVE",
$lng->txt(
'crs_archive_disabled'));
 
  498                        $str = 
$lng->txt(
"crs_from").
" ".strftime(
"%Y-%m-%d %R",$this->course_obj->getArchiveStart()).
" ".
 
  499                                $lng->txt(
"crs_to").
" ".strftime(
"%Y-%m-%d %R",$this->course_obj->getArchiveEnd());
 
  500                        $tmp_tpl->setVariable(
"ARCHIVE",$str);
 
  503                $this->structure = 
'';
 
  505                $tmp_tpl->setVariable(
"STRUCTURE",$this->structure);
 
  507                $this->course_files_obj->writeArchiveFile($tmp_tpl->get(),$this->getName().
'/index.html');
 
  514                $this->course_obj->initCourseItemObject();
 
  515                $this->course_obj->items_obj->setParentId($a_parent_id);
 
  517                $items = $this->course_obj->items_obj->getAllItems();
 
  519                foreach($items as $key => $item)
 
  529                                $this->structure .= 
"<ul>";
 
  532                        $this->structure .= 
"<li>";
 
  534                        if(isset($this->html_files[
"$item[obj_id]"]))
 
  536                                $link = 
"<a href=\"./".$this->html_files[
"$item[obj_id]"].
"\">".$item[
"title"].
"</a>";
 
  540                                $link = $item[
'title'];
 
  542                        $this->structure .= $link;
 
  543                        $this->structure .= 
"</li>";
 
  547                        if($key == (count($items) - 1))
 
  549                                $this->structure .= 
"</ul>";
 
  575                $this->archives = array();
 
  576                $query = 
"SELECT * FROM crs_archives ".
 
  577                        "WHERE course_id = ".$ilDB->quote($this->course_obj->getId(),
'integer').
" ".
 
  578                        "ORDER BY archive_date DESC";
 
  583                        $this->archives[
$row->archive_id][
"archive_id"]         = 
$row->archive_id;
 
  584                        $this->archives[
$row->archive_id][
"archive_type"]       = 
$row->archive_type;
 
  585                        $this->archives[
$row->archive_id][
"archive_date"]       = 
$row->archive_date;
 
  586                        $this->archives[
$row->archive_id][
"archive_size"]       = 
$row->archive_size;
 
  587                        $this->archives[
$row->archive_id][
"archive_name"]       = 
$row->archive_name;
 
  588                        $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
redirection script todo: (a better solution should control the processing via a xml file)