ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 IL_INST_ID.

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  }
const IL_INST_ID
Definition: constants.php:38
global $DIC
Definition: goto.php:24
global $ilDB

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 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  $expLog = new ilLog($expDir, "export.log");
103  $expLog->delete();
104  $expLog->setLogFormat("");
105  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
106 
107  // write xml file
108  $xmlFile = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, "w");
109  fwrite($xmlFile, $this->survey_obj->toXML());
110  fclose($xmlFile);
111 
112  // add media objects which were added with tiny mce
113  $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir);
114 
115  // zip the file
116  ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip");
117 
118  if (@file_exists($this->export_dir . "/" . $this->subdir . ".zip")) {
119  // remove export directory and contents
120  if (@is_dir($this->export_dir . "/" . $this->subdir)) {
121  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
122  }
123  }
124  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
125 
126  return $this->export_dir . "/" . $this->subdir . ".zip";
127  }
logging
Definition: class.ilLog.php:18
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 129 of file class.ilSurveyExport.php.

References $mobs, and ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

130  {
131  $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
132  foreach ($mobs as $mob) {
133  $mob_obj = new ilObjMediaObject($mob);
134  $mob_obj->exportFiles($a_export_dir);
135  unset($mob_obj);
136  }
137  // #14850
138  foreach ($this->survey_obj->questions as $question_id) {
139  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
140  foreach ($mobs as $mob) {
141  $mob_obj = new ilObjMediaObject($mob);
142  $mob_obj->exportFiles($a_export_dir);
143  unset($mob_obj);
144  }
145  }
146  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs
Definition: imgupload.php:54
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: