ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSurveyExport Class Reference

Export class for surveys. More...

+ Collaboration diagram for ilSurveyExport:

Public Member Functions

 __construct ($a_survey_obj, $a_mode="xml")
 Constructor public. More...
 
 getInstId ()
 
 buildExportFile ()
 build export file (complete zip file) More...
 
 buildExportFileXML ()
 build xml export file More...
 
 exportXHTMLMediaObjects ($a_export_dir)
 

Data Fields

 $db
 
 $survey_obj
 
 $inst_id
 
 $mode
 
 $subdir
 
 $filename
 
 $export_dir
 

Detailed Description

Export class for surveys.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 31 of file class.ilSurveyExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyExport::__construct (   $a_survey_obj,
  $a_mode = "xml" 
)

Constructor public.

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

References $DIC, $ilDB, and time.

46  {
47  global $DIC;
48 
49  $ilDB = $DIC->database();
50 
51  $this->survey_obj = $a_survey_obj;
52 
53  $this->db = $ilDB;
54  $this->mode = $a_mode;
55  $this->inst_id = IL_INST_ID;
56 
57  $date = time();
58  switch ($this->mode) {
59  default:
60  $this->export_dir = $this->survey_obj->getExportDirectory();
61  $this->subdir = $date . "__" . $this->inst_id . "__" .
62  "svy" . "_" . $this->survey_obj->getId();
63  $this->filename = $this->subdir . ".xml";
64  break;
65  }
66  }
global $DIC
Definition: saml.php:7
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

Member Function Documentation

◆ buildExportFile()

ilSurveyExport::buildExportFile ( )

build export file (complete zip file)

public

Returns

Definition at line 80 of file class.ilSurveyExport.php.

References buildExportFileXML().

81  {
82  switch ($this->mode) {
83  default:
84  return $this->buildExportFileXML();
85  break;
86  }
87  }
buildExportFileXML()
build xml export file
+ Here is the call graph for this function:

◆ buildExportFileXML()

ilSurveyExport::buildExportFileXML ( )

build xml export file

Definition at line 92 of file class.ilSurveyExport.php.

References date, ilUtil\delDir(), exportXHTMLMediaObjects(), ilUtil\makeDir(), and ilUtil\zip().

Referenced by buildExportFile().

93  {
94 
95  // create directories
96  $this->survey_obj->createExportDirectory();
97  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
98  ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
99 
100  // get Log File
101  $expDir = $this->survey_obj->getExportDirectory();
102  include_once "./Services/Logging/classes/class.ilLog.php";
103  $expLog = new ilLog($expDir, "export.log");
104  $expLog->delete();
105  $expLog->setLogFormat("");
106  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
107 
108  // write xml file
109  $xmlFile = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, "w");
110  fwrite($xmlFile, $this->survey_obj->toXML());
111  fclose($xmlFile);
112 
113  // add media objects which were added with tiny mce
114  $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir);
115 
116  // zip the file
117  ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip");
118 
119  if (@file_exists($this->export_dir . "/" . $this->subdir . ".zip")) {
120  // remove export directory and contents
121  if (@is_dir($this->export_dir . "/" . $this->subdir)) {
122  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
123  }
124  }
125  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
126 
127  return $this->export_dir . "/" . $this->subdir . ".zip";
128  }
logging
Definition: class.ilLog.php:18
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
exportXHTMLMediaObjects($a_export_dir)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXHTMLMediaObjects()

ilSurveyExport::exportXHTMLMediaObjects (   $a_export_dir)

Definition at line 130 of file class.ilSurveyExport.php.

References $mobs, and ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

131  {
132  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
133 
134  $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
135  foreach ($mobs as $mob) {
136  $mob_obj = new ilObjMediaObject($mob);
137  $mob_obj->exportFiles($a_export_dir);
138  unset($mob_obj);
139  }
140  // #14850
141  foreach ($this->survey_obj->questions as $question_id) {
142  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
143  foreach ($mobs as $mob) {
144  $mob_obj = new ilObjMediaObject($mob);
145  $mob_obj->exportFiles($a_export_dir);
146  unset($mob_obj);
147  }
148  }
149  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs
Class ilObjMediaObject.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstId()

ilSurveyExport::getInstId ( )

Definition at line 68 of file class.ilSurveyExport.php.

References $inst_id.

69  {
70  return $this->inst_id;
71  }

Field Documentation

◆ $db

ilSurveyExport::$db

Definition at line 33 of file class.ilSurveyExport.php.

◆ $export_dir

ilSurveyExport::$export_dir

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

◆ $filename

ilSurveyExport::$filename

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

◆ $inst_id

ilSurveyExport::$inst_id

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

Referenced by getInstId().

◆ $mode

ilSurveyExport::$mode

Definition at line 36 of file class.ilSurveyExport.php.

◆ $subdir

ilSurveyExport::$subdir

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

◆ $survey_obj

ilSurveyExport::$survey_obj

Definition at line 34 of file class.ilSurveyExport.php.


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