ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseArchives Class Reference

class ilCourseArchives More...

+ Inheritance diagram for ilCourseArchives:
+ Collaboration diagram for ilCourseArchives:

Public Member Functions

 ilCourseArchives (&$course_obj)
 getArchives ()
 getArchive ($a_id)
 getPublicArchives ()
 setType ($a_type)
 getType ()
 setDate ($a_date)
 getDate ()
 setSize ($a_size)
 getSize ()
 setName ($a_name)
 getName ()
 setLanguage ($a_lang_code)
 getLanguage ()
 getArchiveFile ($a_id)
 addXML ($a_selection="")
 Add XML archive.
 addHTML ()
 add ()
 delete ($a_id)
 deleteAll ()
 initCourseFilesObject ()
 initCourseXMLWriter ()
 __addZipFiles ($a_parent_id, $a_selection="")
 Add zip files to folder.
 __addHTMLFiles ($a_parent_id)
 __addCourseHTML ()
 __buildStructure (&$tmp_tpl, $a_parent_id)
 cloneArchives ()
 Clone archives.
 __read ()

Data Fields

 $course_obj
 $ilias
 $ilErr
 $ilDB
 $tree
 $lng
 $archive_type
 $archive_date
 $archive_size
 $archive_name
 $archive_lang
 $course_files_obj
 $course_xml_writer

Private Attributes

 $fss_storage

Detailed Description

class ilCourseArchives

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilCourseArchives.php 19032 2009-02-18 11:01:59Z smeyer

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

Member Function Documentation

ilCourseArchives::__addCourseHTML ( )

Definition at line 398 of file class.ilCourseArchives.php.

References $ilias, $lng, $tpl, __buildStructure(), getLanguage(), and getName().

Referenced by addHTML().

{
global $tpl,$ilias;
// Get Language
if($this->getLanguage())
{
$lng =& new ilLanguage($this->getLanguage());
$lng->loadLanguageModule('crs');
}
else
{
}
$tmp_tpl =& new ilTemplate("tpl.crs_export.html",true,true,'Modules/Course');
$this->course_files_obj->copyFile($tpl->tplPath.'/'.$ilias->account->prefs["style"].'.css',
$this->course_files_obj->getArchiveDirectory().'/'.$this->getName().'/default.css');
$tmp_tpl->setVariable('TITLE',$lng->txt('crs_export'));
$tmp_tpl->setVariable("CRS_STRUCTURE",$lng->txt('crs_structure'));
$tmp_tpl->setVariable("DETAILS_TITLE",$lng->txt("crs_details"));
// SET TXT VARIABLES
$tmp_tpl->setVariable("TXT_SYLLABUS",$lng->txt("crs_syllabus"));
$tmp_tpl->setVariable("TXT_CONTACT",$lng->txt("crs_contact"));
$tmp_tpl->setVariable("TXT_CONTACT_NAME",$lng->txt("crs_contact_name"));
$tmp_tpl->setVariable("TXT_CONTACT_RESPONSIBILITY",$lng->txt("crs_contact_responsibility"));
$tmp_tpl->setVariable("TXT_CONTACT_EMAIL",$lng->txt("crs_contact_email"));
$tmp_tpl->setVariable("TXT_CONTACT_PHONE",$lng->txt("crs_contact_phone"));
$tmp_tpl->setVariable("TXT_CONTACT_CONSULTATION",$lng->txt("crs_contact_consultation"));
$tmp_tpl->setVariable("TXT_DATES",$lng->txt("crs_dates"));
$tmp_tpl->setVariable("TXT_ACTIVATION",$lng->txt("crs_activation"));
$tmp_tpl->setVariable("TXT_SUBSCRIPTION",$lng->txt("crs_subscription"));
$tmp_tpl->setVariable("TXT_ARCHIVE",$lng->txt("crs_archive"));
// FILL
$tmp_tpl->setVariable("SYLLABUS",nl2br($this->course_obj->getSyllabus() ?
$this->course_obj->getSyllabus() :
$lng->txt("crs_not_available")));
$tmp_tpl->setVariable("CONTACT_NAME",$this->course_obj->getContactName() ?
$this->course_obj->getContactName() :
$lng->txt("crs_not_available"));
$tmp_tpl->setVariable("CONTACT_RESPONSIBILITY",$this->course_obj->getContactResponsibility() ?
$this->course_obj->getContactResponsibility() :
$lng->txt("crs_not_available"));
$tmp_tpl->setVariable("CONTACT_PHONE",$this->course_obj->getContactPhone() ?
$this->course_obj->getContactPhone() :
$lng->txt("crs_not_available"));
$tmp_tpl->setVariable("CONTACT_CONSULTATION",nl2br($this->course_obj->getContactConsultation() ?
$this->course_obj->getContactConsultation() :
$lng->txt("crs_not_available")));
if($this->course_obj->getContactEmail())
{
$tmp_tpl->setCurrentBlock("email_link");
#$tmp_tpl->setVariable("EMAIL_LINK","ilias.php?baseClass=ilMailGUI&type=new&rcp_to=".$this->course_obj->getContactEmail());
$tmp_tpl->setVariable("CONTACT_EMAIL",$this->course_obj->getContactEmail());
$tmp_tpl->parseCurrentBlock();
}
else
{
$tmp_tpl->setCurrentBlock("no_mail");
$tmp_tpl->setVariable("NO_CONTACT_EMAIL",$this->course_obj->getContactEmail());
$tmp_tpl->parseCurrentBlock();
}
if($this->course_obj->getActivationUnlimitedStatus())
{
$tmp_tpl->setVariable("ACTIVATION",$lng->txt('crs_unlimited'));
}
else
{
$str = $lng->txt("crs_from")." ".strftime("%Y-%m-%d %R",$this->course_obj->getActivationStart())." ".
$lng->txt("crs_to")." ".strftime("%Y-%m-%d %R",$this->course_obj->getActivationEnd());
$tmp_tpl->setVariable("ACTIVATION",$str);
}
if($this->course_obj->getSubscriptionUnlimitedStatus())
{
$tmp_tpl->setVariable("SUBSCRIPTION",$lng->txt('crs_unlimited'));
}
else
{
$str = $lng->txt("crs_from")." ".strftime("%Y-%m-%d %R",$this->course_obj->getSubscriptionStart())." ".
$lng->txt("crs_to")." ".strftime("%Y-%m-%d %R",$this->course_obj->getSubscriptionEnd());
$tmp_tpl->setVariable("SUBSCRIPTION",$str);
}
if($this->course_obj->getArchiveType() == $this->course_obj->ARCHIVE_DISABLED)
{
$tmp_tpl->setVariable("ARCHIVE",$lng->txt('crs_archive_disabled'));
}
else
{
$str = $lng->txt("crs_from")." ".strftime("%Y-%m-%d %R",$this->course_obj->getArchiveStart())." ".
$lng->txt("crs_to")." ".strftime("%Y-%m-%d %R",$this->course_obj->getArchiveEnd());
$tmp_tpl->setVariable("ARCHIVE",$str);
}
$this->structure = '';
$this->__buildStructure($tmp_tpl,$this->course_obj->getRefId());
$tmp_tpl->setVariable("STRUCTURE",$this->structure);
$this->course_files_obj->writeArchiveFile($tmp_tpl->get(),$this->getName().'/index.html');
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseArchives::__addHTMLFiles (   $a_parent_id)

Definition at line 371 of file class.ilCourseArchives.php.

References ilObjectFactory\getInstanceByRefId(), and getName().

Referenced by addHTML().

{
$this->course_obj->initCourseItemObject();
$this->course_obj->items_obj->setParentId($a_parent_id);
foreach($this->course_obj->items_obj->getAllItems() as $item)
{
if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'],false))
{
continue;
}
if($abs_dir_name = $tmp_obj->getHTMLDirectory())
{
$new_name = 'il_'.$this->ilias->getSetting('inst_id').'_'.$tmp_obj->getType().'_'.$item['obj_id'];
$this->course_files_obj->addDirectory($this->getName().'/objects/'.$new_name);
$this->course_files_obj->rCopy($abs_dir_name,$this->getName().'/objects/'.$new_name);
// Store filename in hashtable (used for create course html tree)
$this->html_files["$item[obj_id]"] = "objects/".$new_name."/index.html";
}
$this->__addHTMLFiles($item['child']);
unset($tmp_obj);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseArchives::__addZipFiles (   $a_parent_id,
  $a_selection = "" 
)

Add zip files to folder.

Parameters
arrayselection array: key is ref_id, value is "last_file", "omit" or "create"

Definition at line 313 of file class.ilCourseArchives.php.

References ilExport\_getExportDirectory(), ilExport\_getLastExportFileInformation(), ilObjectFactory\getInstanceByRefId(), and getName().

Referenced by addXML().

{
$this->course_obj->initCourseItemObject();
$this->course_obj->items_obj->setParentId($a_parent_id);
foreach($this->course_obj->items_obj->getAllItems() as $item)
{
if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'],false))
{
continue;
}
$action = $a_selection[$item['child']];
if ($a_selection == "")
{
$action = "create";
}
if ($action == "omit")
{
continue;
}
if ($action == "create")
{
$abs_file_name = $tmp_obj->getXMLZip();
}
else
{
include_once("./Services/Export/classes/class.ilExport.php");
$info = ilExport::_getLastExportFileInformation($item['obj_id'], "xml", $item['type']);
$abs_file_name = ilExport::_getExportDirectory($item['obj_id'], "xml", $item['type'])."/".$info["file"];
if (!@is_file($abs_file_name))
{
$abs_file_name = "";
}
}
// must return absolute path to zip file
if ($abs_file_name != "")
{
//$new_name = 'il_'.$this->ilias->getSetting('inst_id').'_'.$tmp_obj->getType().'_'.$item['obj_id'].'.zip';
$new_name = basename($abs_file_name);
$this->course_files_obj->copyFile($abs_file_name,$this->course_files_obj->getArchiveDirectory().'/'.
$this->getName().'/'.$new_name);
if (is_file($this->course_files_obj->getArchiveDirectory().'/'.
$this->getName().'/'.$new_name))
{
$this->copied_files[] = array("title" => $item['title'],
"file" => $new_name, "type" => $item['type']);
}
}
$this->__addZipFiles($item['child']);
unset($tmp_obj);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseArchives::__buildStructure ( $tmp_tpl,
  $a_parent_id 
)

Definition at line 507 of file class.ilCourseArchives.php.

References $key, and ilObjectFactory\getInstanceByRefId().

Referenced by __addCourseHTML().

{
$this->course_obj->initCourseItemObject();
$this->course_obj->items_obj->setParentId($a_parent_id);
$items = $this->course_obj->items_obj->getAllItems();
foreach($items as $key => $item)
{
if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'],false))
{
continue;
}
if($key == 0)
{
$this->structure .= "<ul>";
}
$this->structure .= "<li>";
if(isset($this->html_files["$item[obj_id]"]))
{
$link = "<a href=\"./".$this->html_files["$item[obj_id]"]."\">".$item["title"]."</a>";
}
else
{
$link = $item['title'];
}
$this->structure .= $link;
$this->structure .= "</li>";
$this->__buildStructure($tmp_tpl,$item['child']);
if($key == (count($items) - 1))
{
$this->structure .= "</ul>";
}
unset($tmp_obj);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseArchives::__read ( )

Definition at line 566 of file class.ilCourseArchives.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and ilDB\query().

Referenced by add(), delete(), and ilCourseArchives().

{
global $ilDB;
$this->archives = array();
$query = "SELECT * FROM crs_archives ".
"WHERE course_id = ".$ilDB->quote($this->course_obj->getId(),'integer')." ".
"ORDER BY archive_date DESC";
$res = $this->ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->archives[$row->archive_id]["archive_id"] = $row->archive_id;
$this->archives[$row->archive_id]["archive_type"] = $row->archive_type;
$this->archives[$row->archive_id]["archive_date"] = $row->archive_date;
$this->archives[$row->archive_id]["archive_size"] = $row->archive_size;
$this->archives[$row->archive_id]["archive_name"] = $row->archive_name;
$this->archives[$row->archive_id]["archive_lang"] = $row->archive_lang;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseArchives::add ( )

Definition at line 239 of file class.ilCourseArchives.php.

References $ilDB, $query, $res, and __read().

Referenced by addHTML(), and addXML().

{
global $ilDB;
$next_id = $ilDB->nextId('crs_archives');
$query = "INSERT INTO crs_archives (archive_id,course_id,archive_name,archive_type,archive_date,archive_size,archive_lang) ".
"VALUES (" .
$ilDB->quote($next_id,'integer').", ".
$ilDB->quote($this->course_obj->getId(),'integer').",".
$ilDB->quote($this->getName(),'text').",".
$ilDB->quote($this->getType(),'integer').", ".
$ilDB->quote($this->getDate(),'integer').",".
$ilDB->quote($this->getSize(),'integer').",".
$ilDB->quote($this->getLanguage(),'text').
")";
$res = $ilDB->manipulate($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseArchives::addHTML ( )

Definition at line 209 of file class.ilCourseArchives.php.

References __addCourseHTML(), __addHTMLFiles(), add(), getDate(), getName(), initCourseFilesObject(), setDate(), setName(), setSize(), and setType().

{
$this->setType($this->ARCHIVE_HTML);
$this->setDate(time());
$this->setName($this->getDate().'__'.$this->ilias->getSetting('inst_id').'__crs_'.$this->course_obj->getId());
// Step one create folder
$this->course_files_obj->addArchiveSubDirectory($this->getName());
// Step two, create child html
$this->course_files_obj->addArchiveSubDirectory($this->getName().'/objects');
$this->__addHTMLFiles($this->course_obj->getRefId());
// Step three create course html
$this->__addCourseHTML();
// Step three create copy in web dir
$this->course_files_obj->createArchiveOnlineVersion($this->getName());
// Step four zip
$this->setSize($this->course_files_obj->zipArchive($this->getName(),$this->getName().'.zip'));
// Finally add entry in crs_archives table
$this->add();
return true;
}

+ Here is the call graph for this function:

ilCourseArchives::addXML (   $a_selection = "")

Add XML archive.

Parameters
arrayselection array: key is ref_id, value is "last_file", "omit" or "create"

Definition at line 170 of file class.ilCourseArchives.php.

References __addZipFiles(), ilExport\_generateIndexFile(), add(), getName(), initCourseFilesObject(), initCourseXMLWriter(), setDate(), setName(), setSize(), and setType().

{
$this->setType($this->ARCHIVE_XML);
$this->setName(time().'__'.$this->ilias->getSetting('inst_id').'__crs_'.$this->course_obj->getId());
$this->setDate(time());
// Step one create folder
$this->course_files_obj->addArchiveSubDirectory($this->getName());
// Step two create course xml
$this->course_xml_writer->start();
$this->course_files_obj->writeArchiveFile($this->course_xml_writer->getXML(),$this->getName().'/'.$this->getName().'.xml');
// Step three create child object xml
// add objects directory
$this->course_files_obj->addArchiveSubDirectory($this->getName().'/objects');
$this->copied_files = array();
$this->__addZipFiles($this->course_obj->getRefId(), $a_selection);
// Step four: Write index file
include_once("./Services/Export/classes/class.ilExport.php");
ilExport::_generateIndexFile($this->course_files_obj->getArchiveDirectory().'/'.
$this->getName().'/index.html', $this->course_obj->getId(),$this->copied_files);
// Step five zip
$this->setSize($this->course_files_obj->zipArchive($this->getName(),$this->getName().'.zip'));
// Finally add entry in crs_archives table
$this->add();
return true;
}

+ Here is the call graph for this function:

ilCourseArchives::cloneArchives ( )

Clone archives.

public

Parameters

Definition at line 560 of file class.ilCourseArchives.php.

{
}
ilCourseArchives::delete (   $a_id)

Definition at line 260 of file class.ilCourseArchives.php.

References $ilDB, $query, $res, __read(), and initCourseFilesObject().

{
global $ilDB;
// Delete in file system
$this->course_files_obj->deleteArchive($this->archives[$a_id]["archive_name"]);
$query = "DELETE FROM crs_archives ".
"WHERE course_id = ".$ilDB->quote($this->course_obj->getId(),'integer')." ".
"AND archive_id = ".$ilDB->quote($a_id,'integer')." ";
$res = $ilDB->manipulate($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilCourseArchives::deleteAll ( )

Definition at line 278 of file class.ilCourseArchives.php.

References getArchives().

{
foreach($this->getArchives() as $id => $archive)
{
$this->delete($id);
}
}

+ Here is the call graph for this function:

ilCourseArchives::getArchive (   $a_id)

Definition at line 81 of file class.ilCourseArchives.php.

Referenced by getArchiveFile().

{
return $this->archives[$a_id];
}

+ Here is the caller graph for this function:

ilCourseArchives::getArchiveFile (   $a_id)

Definition at line 149 of file class.ilCourseArchives.php.

References getArchive(), and initCourseFilesObject().

{
$archive = $this->getArchive($a_id);
if(PATH_TO_ZIP)
{
return $this->course_files_obj->getArchiveDirectory().'/'.$archive['archive_name'].'.zip';
}
else
{
return $this->course_files_obj->getArchiveDirectory().'/'.$archive['archive_name'];
}
}

+ Here is the call graph for this function:

ilCourseArchives::getArchives ( )

Definition at line 76 of file class.ilCourseArchives.php.

Referenced by deleteAll().

{
return $this->archives;
}

+ Here is the caller graph for this function:

ilCourseArchives::getDate ( )

Definition at line 118 of file class.ilCourseArchives.php.

Referenced by addHTML().

{
return $this->archive_date ? $this->archive_date : time();
}

+ Here is the caller graph for this function:

ilCourseArchives::getLanguage ( )

Definition at line 143 of file class.ilCourseArchives.php.

References $archive_lang.

Referenced by __addCourseHTML().

{
}

+ Here is the caller graph for this function:

ilCourseArchives::getName ( )

Definition at line 135 of file class.ilCourseArchives.php.

References $archive_name.

Referenced by __addCourseHTML(), __addHTMLFiles(), __addZipFiles(), addHTML(), and addXML().

{
}

+ Here is the caller graph for this function:

ilCourseArchives::getPublicArchives ( )

Definition at line 86 of file class.ilCourseArchives.php.

{
foreach($this->archives as $id => $archive)
{
if($archive['archive_type'] == $this->ARCHIVE_XML)
{
continue;
}
if($this->course_obj->getArchiveType() != $this->course_obj->ARCHIVE_DOWNLOAD and
$archive['archive_type'] == $this->ARCHIVE_PDF)
{
continue;
}
$public_archives[$id] = $archive;
}
return $public_archives ? $public_archives : array();
}
ilCourseArchives::getSize ( )

Definition at line 127 of file class.ilCourseArchives.php.

References $archive_size.

{
}
ilCourseArchives::getType ( )

Definition at line 109 of file class.ilCourseArchives.php.

{
return $this->archive_type ? $this->archive_type : $this->ARCHIVE_XML;
}
ilCourseArchives::ilCourseArchives ( $course_obj)

Definition at line 56 of file class.ilCourseArchives.php.

References $course_obj, $ilDB, $ilErr, $ilias, $lng, $tree, and __read().

{
$this->ilias =& $ilias;
$this->ilErr =& $ilErr;
$this->ilDB =& $ilDB;
$this->lng =& $lng;
$this->tree =& $tree;
$this->ARCHIVE_XML = 1;
$this->ARCHIVE_HTML = 2;
$this->ARCHIVE_PDF = 3;
$this->course_obj =& $course_obj;
$this->__read();
}

+ Here is the call graph for this function:

ilCourseArchives::initCourseFilesObject ( )

Definition at line 286 of file class.ilCourseArchives.php.

Referenced by addHTML(), addXML(), delete(), and getArchiveFile().

{
if(!is_object($this->course_files_obj))
{
include_once('Modules/Course/classes/class.ilFSStorageCourse.php');
$this->course_files_obj = new ilFSStorageCourse($this->course_obj->getId());
}
return true;
}

+ Here is the caller graph for this function:

ilCourseArchives::initCourseXMLWriter ( )

Definition at line 296 of file class.ilCourseArchives.php.

Referenced by addXML().

{
if(!is_object($this->course_xml_writer))
{
include_once "./Modules/Course/classes/class.ilCourseXMLWriter.php";
$this->course_xml_writer =& new ilCourseXMLWriter($this->course_obj);
}
return true;
}

+ Here is the caller graph for this function:

ilCourseArchives::setDate (   $a_date)

Definition at line 114 of file class.ilCourseArchives.php.

Referenced by addHTML(), and addXML().

{
$this->archive_date = $a_date;
}

+ Here is the caller graph for this function:

ilCourseArchives::setLanguage (   $a_lang_code)

Definition at line 139 of file class.ilCourseArchives.php.

{
$this->archive_lang = $a_lang_code;
}
ilCourseArchives::setName (   $a_name)

Definition at line 131 of file class.ilCourseArchives.php.

Referenced by addHTML(), and addXML().

{
$this->archive_name = $a_name;
}

+ Here is the caller graph for this function:

ilCourseArchives::setSize (   $a_size)

Definition at line 123 of file class.ilCourseArchives.php.

Referenced by addHTML(), and addXML().

{
$this->archive_size = $a_size;
}

+ Here is the caller graph for this function:

ilCourseArchives::setType (   $a_type)

Definition at line 105 of file class.ilCourseArchives.php.

Referenced by addHTML(), and addXML().

{
$this->archive_type = $a_type;
}

+ Here is the caller graph for this function:

Field Documentation

ilCourseArchives::$archive_date

Definition at line 45 of file class.ilCourseArchives.php.

ilCourseArchives::$archive_lang

Definition at line 48 of file class.ilCourseArchives.php.

Referenced by getLanguage().

ilCourseArchives::$archive_name

Definition at line 47 of file class.ilCourseArchives.php.

Referenced by getName().

ilCourseArchives::$archive_size

Definition at line 46 of file class.ilCourseArchives.php.

Referenced by getSize().

ilCourseArchives::$archive_type

Definition at line 44 of file class.ilCourseArchives.php.

ilCourseArchives::$course_files_obj

Definition at line 50 of file class.ilCourseArchives.php.

ilCourseArchives::$course_obj

Definition at line 37 of file class.ilCourseArchives.php.

Referenced by ilCourseArchives().

ilCourseArchives::$course_xml_writer

Definition at line 51 of file class.ilCourseArchives.php.

ilCourseArchives::$fss_storage
private

Definition at line 53 of file class.ilCourseArchives.php.

ilCourseArchives::$ilDB

Definition at line 40 of file class.ilCourseArchives.php.

Referenced by __read(), add(), delete(), and ilCourseArchives().

ilCourseArchives::$ilErr

Definition at line 39 of file class.ilCourseArchives.php.

Referenced by ilCourseArchives().

ilCourseArchives::$ilias

Definition at line 38 of file class.ilCourseArchives.php.

Referenced by __addCourseHTML(), and ilCourseArchives().

ilCourseArchives::$lng

Definition at line 42 of file class.ilCourseArchives.php.

Referenced by __addCourseHTML(), and ilCourseArchives().

ilCourseArchives::$tree

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

Referenced by ilCourseArchives().


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