ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBibliographicDataSet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12 
16  protected $db;
20  protected $data = array();
27  protected $record_field_ids_2_storage = array();
31  protected $import_bib_object;
35  protected $user;
39  protected $import_temp_refs = array();
43  protected $import_temp_refs_props = array();
44 
45 
46  public function __construct()
47  {
48  global $DIC;
49  $ilDB = $DIC['ilDB'];
50  $ilUser = $DIC['ilUser'];
51  parent::__construct();
52  $this->db = $ilDB;
53  $this->user = $ilUser;
54  }
55 
56 
60  public function getSupportedVersions()
61  {
62  return array( '4.5.0' );
63  }
64 
65 
72  public function getXmlNamespace($a_entity, $a_schema_version)
73  {
74  return 'http://www.ilias.de/xml/Modules/Bibliographic/' . $a_entity;
75  }
76 
77 
85  public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
86  {
87  switch ($a_entity) {
88  case 'bibl':
89  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['id'])) {
90  // container content
91  $new_obj = ilObjectFactory::getInstanceByObjId($new_id, false);
92  } else {
93  $new_obj = new ilObjBibliographic();
94  }
95  $new_obj->setTitle($a_rec['title']);
96  $new_obj->setDescription($a_rec['description']);
97  $new_obj->setFilename($a_rec['fileName']);
98  $new_obj->setOnline(false);
99  if (!$new_obj->getId()) {
100  $new_obj->create();
101  }
102  $this->import_bib_object = $new_obj;
103  $a_mapping->addMapping('Modules/Bibliographic', 'bibl', $a_rec['id'], $new_obj->getId());
104  $this->importLibraryFile($a_mapping);
105  break;
106  }
107  }
108 
109 
118  protected function getTypes($a_entity, $a_version)
119  {
120  switch ($a_entity) {
121  case 'bibl':
122  return array(
123  "id" => "integer",
124  "title" => "text",
125  "description" => "text",
126  "filename" => "text",
127  'is_online' => 'integer',
128  );
129  default:
130  return array();
131  }
132  }
133 
134 
146  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
147  {
148  return false;
149  }
150 
151 
159  public function readData($a_entity, $a_version, $a_ids)
160  {
161  $this->data = array();
162  if (!is_array($a_ids)) {
163  $a_ids = array( $a_ids );
164  }
165  $this->_readData($a_entity, $a_ids);
166  }
167 
168 
175  protected function _readData($a_entity, $a_ids)
176  {
177  switch ($a_entity) {
178  case 'bibl':
179  foreach ($a_ids as $bibl_id) {
180  if (ilObject::_lookupType($bibl_id) == 'bibl') {
181  $obj = new ilObjBibliographic($bibl_id);
182  $data = array(
183  'id' => $bibl_id,
184  'title' => $obj->getTitle(),
185  'description' => $obj->getDescription(),
186  'fileName' => $obj->getFilename(),
187  'is_online' => $obj->getOnline(),
188  );
189  $this->data[] = $data;
190  }
191  }
192  break;
193  default:
194  }
195  }
196 
197 
202  public function exportLibraryFile($a_id)
203  {
204  $obj = new ilObjBibliographic($a_id);
205  $fileAbsolutePath = $obj->getLegacyAbsolutePath();
206  copy($fileAbsolutePath, $this->absolute_export_dir . "/" . $obj->getFilename());
207  }
208 
209 
213  public function importLibraryFile($a_mapping)
214  {
215  $import_path = $this->getImportDirectory() . "/Modules/Bibliographic/set_1/expDir_1/"
216  . $this->import_bib_object->getFilename();
217  $new_id = $this->import_bib_object->getId();
218  $new_path = ilUtil::getDataDir() . "/bibl/" . $new_id;
219  mkdir($new_path);
220  copy($import_path, $new_path . "/" . $this->import_bib_object->getFilename());
221  }
222 }
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Return dependencies form entities to other entities (in our case these are all the DB relations) ...
Bibliographic dataset class.
global $DIC
Definition: saml.php:7
getXmlNamespace($a_entity, $a_schema_version)
_readData($a_entity, $a_ids)
Build data array, data is read from cache except bibl object itself.
getImportDirectory()
Get import directory.
user()
Definition: user.php:4
readData($a_entity, $a_version, $a_ids)
Read data from Cache for a given entity and ID(s)
$ilUser
Definition: imgupload.php:18
getTypes($a_entity, $a_version)
Map XML attributes of entities to datatypes (text, integer...)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static getDataDir()
get data directory (outside webspace)
$this data['403_header']
global $ilDB
Class ilObjBibliographic.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)