ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilGlossaryExporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Export/classes/class.ilXmlExporter.php");
5 
14 {
15  private $ds;
16 
20  public function init()
21  {
22  include_once("./Modules/Glossary/classes/class.ilGlossaryDataSet.php");
23  $this->ds = new ilGlossaryDataSet();
24  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
25  $this->ds->setDSPrefix("ds");
26  }
27 
36  public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
37  {
38  if ($a_entity == "glo") {
39  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
40  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
41 
42  $md_ids = array();
43 
44  // glo related ids
45  foreach ($a_ids as $id) {
46  $md_ids[] = $id . ":0:glo";
47  }
48 
49  // definition related ids
50  $page_ids = array();
51  foreach ($a_ids as $id) {
52  // workaround for #0023923
53  $all_refs = ilObject::_getAllReferences($id);
54  $ref_id = current($all_refs);
55 
56  // see #29014, we include referenced terms in the export as well
58  $ref_id,
59  "",
60  "",
61  "",
62  0,
63  false,
64  null,
65  true
66  );
67 
68  foreach ($terms as $t) {
70  foreach ($defs as $d) {
71  $page_ids[] = "gdf:" . $d["id"];
72  $md_ids[] = $id . ":" . $d["id"] . ":gdf";
73  }
74  }
75  }
76  // definition pages and their metadat
77  $deps = array(
78  array(
79  "component" => "Services/COPage",
80  "entity" => "pg",
81  "ids" => $page_ids),
82  array(
83  "component" => "Services/MetaData",
84  "entity" => "md",
85  "ids" => $md_ids),
86  );
87 
88  // taxonomy
89  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
90  $tax_ids = array();
91  foreach ($a_ids as $id) {
92  $t_ids = ilObjTaxonomy::getUsageOfObject($id);
93  if (count($t_ids) > 0) {
94  $tax_ids[$t_ids[0]] = $t_ids[0];
95  }
96  }
97  if (sizeof($tax_ids)) {
98  $deps[] = array(
99  "component" => "Services/Taxonomy",
100  "entity" => "tax",
101  "ids" => $tax_ids
102  );
103  }
104 
105  // advanced metadata
106  $advmd_ids = array();
107  foreach ($a_ids as $id) {
108  $rec_ids = $this->getActiveAdvMDRecords($id);
109  if (sizeof($rec_ids)) {
110  foreach ($rec_ids as $rec_id) {
111  $advmd_ids[] = $id . ":" . $rec_id;
112  }
113  }
114  }
115  if (sizeof($advmd_ids)) {
116  $deps[] = array(
117  "component" => "Services/AdvancedMetaData",
118  "entity" => "advmd",
119  "ids" => $advmd_ids
120  );
121  }
122 
123  // style
124  $obj_ids = (is_array($a_ids))
125  ? $a_ids
126  : array($a_ids);
127  $deps[] = array(
128  "component" => "Services/Style",
129  "entity" => "object_style",
130  "ids" => $obj_ids
131  );
132 
133  // service settings
134  $deps[] = array(
135  "component" => "Services/Object",
136  "entity" => "common",
137  "ids" => $a_ids);
138 
139  return $deps;
140  }
141  return array();
142  }
143 
144  protected function getActiveAdvMDRecords($a_id)
145  {
146  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
147  $active = array();
148  // selected globals
149  $sel_globals = ilAdvancedMDRecord::getObjRecSelection($a_id, "term");
150 
151  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("glo", "term") as $record_obj) {
152  // local ones and globally activated for the object
153  if ($record_obj->getParentObject() == $a_id || in_array($record_obj->getRecordId(), $sel_globals)) {
154  $active[] = $record_obj->getRecordId();
155  }
156  }
157 
158  return $active;
159  }
160 
169  public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
170  {
171  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
172 
173  /*include_once './Modules/Glossary/classes/class.ilObjGlossary.php';
174  $glo = new ilObjGlossary($a_id,false);
175 
176  include_once './Modules/Glossary/classes/class.ilGlossaryExport.php';
177  $exp = new ilGlossaryExport($glo,'xml');
178  $zip = $exp->buildExportFile();*/
179  }
180 
188  public function getValidSchemaVersions($a_entity)
189  {
190  return array(
191  "5.4.0" => array(
192  "namespace" => "http://www.ilias.de/Modules/Glossary/htlm/5_4",
193  "xsd_file" => "ilias_glo_5_4.xsd",
194  "uses_dataset" => true,
195  "min" => "5.4.0",
196  "max" => ""),
197  "5.1.0" => array(
198  "namespace" => "http://www.ilias.de/Modules/Glossary/htlm/5_1",
199  "xsd_file" => "ilias_glo_5_1.xsd",
200  "uses_dataset" => true,
201  "min" => "5.1.0",
202  "max" => ""),
203  "4.1.0" => array(
204  "namespace" => "http://www.ilias.de/Modules/Glossary/htlm/4_1",
205  "xsd_file" => "ilias_glo_4_1.xsd",
206  "uses_dataset" => false,
207  "min" => "4.1.0",
208  "max" => "")
209  );
210  }
211 }
Exporter class for html learning modules.
static getDefinitionList($a_term_id)
static
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _getAllReferences($a_id)
get all reference ids of object
Xml Exporter class.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
Glossary Data set class.
static getTermList( $a_glo_ref_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
static _getActivatedRecordsByObjectType($a_obj_type, $a_sub_type="", $a_only_optional=false)
Get activated records by object type.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296