ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_once("./Services/DataSet/classes/class.ilDataSet.php");
4 require_once('class.ilObjBibliographic.php');
12 
16  protected $db;
20  protected $data = array();
30  protected $import_bib_object;
34  protected $user;
38  protected $import_temp_refs = array();
43 
44 
45  public function __construct() {
46  global $DIC;
47  $ilDB = $DIC['ilDB'];
48  $ilUser = $DIC['ilUser'];
49  parent::__construct();
50  $this->db = $ilDB;
51  $this->user = $ilUser;
52  }
53 
54 
58  public function getSupportedVersions() {
59  return array( '4.5.0' );
60  }
61 
62 
69  public function getXmlNamespace($a_entity, $a_schema_version) {
70  return 'http://www.ilias.de/xml/Modules/Bibliographic/' . $a_entity;
71  }
72 
73 
81  public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) {
82  global $DIC;
83  $ilDB = $DIC['ilDB'];
84  switch ($a_entity) {
85  case 'bibl':
86  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['id']))
87  {
88  // container content
89  $new_obj = ilObjectFactory::getInstanceByObjId($new_id,false);
90  } else {
91  $new_obj = new ilObjBibliographic();
92  }
93  $new_obj->setTitle($a_rec['title']);
94  $new_obj->setDescription($a_rec['description']);
95  $new_obj->setFilename($a_rec['fileName']);
96  $new_obj->setOnline(false);
97  if (!$new_obj->getId()) {
98  $new_obj->create();
99  }
100  $this->import_bib_object = $new_obj;
101  $a_mapping->addMapping('Modules/Bibliographic', 'bibl', $a_rec['id'], $new_obj->getId());
102  $this->importLibraryFile($a_mapping);
103  break;
104  }
105  }
106 
107 
116  protected function getTypes($a_entity, $a_version) {
117  switch ($a_entity) {
118  case 'bibl':
119  return array(
120  "id" => "integer",
121  "title" => "text",
122  "description" => "text",
123  "filename" => "text",
124  'is_online' => 'integer',
125  );
126  default:
127  return array();
128  }
129  }
130 
131 
142  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids) {
143  return false;
144  }
145 
146 
154  public function readData($a_entity, $a_version, $a_ids) {
155  $this->data = array();
156  if (! is_array($a_ids)) {
157  $a_ids = array( $a_ids );
158  }
159  $this->_readData($a_entity, $a_ids);
160  }
161 
162 
169  protected function _readData($a_entity, $a_ids) {
170  switch ($a_entity) {
171  case 'bibl':
172  foreach ($a_ids as $bibl_id) {
173  if (ilObject::_lookupType($bibl_id) == 'bibl') {
174  $obj = new ilObjBibliographic($bibl_id);
175  $data = array(
176  'id' => $bibl_id,
177  'title' => $obj->getTitle(),
178  'description' => $obj->getDescription(),
179  'fileName' => $obj->getFilename(),
180  'is_online' => $obj->getOnline(),
181  );
182  $this->data[] = $data;
183  }
184  }
185  break;
186  default:
187  }
188  }
189 
190 
195  public function exportLibraryFile($a_id) {
196  $obj = new ilObjBibliographic($a_id);
197  copy($obj->getFileAbsolutePath(), $this->absolute_export_dir . "/" . $obj->getFilename());
198  }
199 
200 
204  public function importLibraryFile($a_mapping) {
205  $import_path = $this->getImportDirectory()
206  . "/Modules/Bibliographic/set_1/expDir_1/" . $this->import_bib_object->getFilename();
207  $new_id = $this->import_bib_object->getId();
208  $new_path = ilUtil::getDataDir() . "/bibl/" . $new_id;
209  mkdir($new_path);
210  copy($import_path, $new_path . "/" . $this->import_bib_object->getFilename());
211  // this will write the source file entry to db
212  $this->import_bib_object->update();
213  }
214 }
Add some data
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.
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
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getDataDir()
get data directory (outside webspace)
global $ilDB
global $DIC
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)