ILIAS  release_8 Revision v8.24
class.ilBibliographicDataSet.php
Go to the documentation of this file.
1<?php
20use ILIAS\ResourceStorage\StorageHandler\FileSystemStorageHandler;
23use ILIAS\ResourceStorage\Revision\Repository\RevisionARRepository;
24use ILIAS\ResourceStorage\Resource\Repository\ResourceARRepository;
25use ILIAS\ResourceStorage\Information\Repository\InformationARRepository;
26use ILIAS\ResourceStorage\Stakeholder\Repository\StakeholderARRepository;
29
37{
41 protected $storage;
42 protected \ilObjBibliographicStakeholder $stakeholder;
50 protected $user;
51 protected array $import_temp_refs = array();
52 protected array $import_temp_refs_props = array();
53
54
55 public function __construct()
56 {
57 global $DIC;
58 $ilDB = $DIC['ilDB'];
59 $ilUser = $DIC['ilUser'];
60 $IRSS = $DIC['resource_storage'];
62 $this->db = $ilDB;
63 $this->user = $ilUser;
64 $this->storage = $IRSS;
65 $this->stakeholder = new ilObjBibliographicStakeholder();
66 }
67
68
69 public function getSupportedVersions(): array
70 {
71 return array('4.5.0');
72 }
73
74
75 public function getXmlNamespace(string $a_entity, string $a_schema_version): string
76 {
77 return 'http://www.ilias.de/xml/Modules/Bibliographic/' . $a_entity;
78 }
79
80
81 public function importRecord(
82 string $a_entity,
83 array $a_types,
84 array $a_rec,
85 ilImportMapping $a_mapping,
86 string $a_schema_version
87 ): void {
88 switch ($a_entity) {
89 case 'bibl':
90 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['id'])) {
91 // container content
92 $new_obj = ilObjectFactory::getInstanceByObjId($new_id, false);
93 } else {
94 $new_obj = new ilObjBibliographic();
95 }
99 $new_obj->setTitle($a_rec['title']);
100 $new_obj->setDescription($a_rec['description']);
101 $new_obj->setFilename($a_rec['fileName']);
102 $new_obj->setOnline(false);
103 if (!$new_obj->getId()) {
104 $new_obj->create();
105 }
106 $this->import_bib_object = $new_obj;
107 $a_mapping->addMapping('Modules/Bibliographic', 'bibl', $a_rec['id'], $new_obj->getId());
108 $this->importLibraryFile($a_mapping);
109 break;
110 }
111 }
112
113
117 protected function getTypes(string $a_entity, string $a_version): array
118 {
119 switch ($a_entity) {
120 case 'bibl':
121 return array(
122 "id" => "integer",
123 "title" => "text",
124 "description" => "text",
125 "filename" => "text",
126 "is_online" => "integer",
127 );
128 default:
129 return array();
130 }
131 }
132
133
138 protected function getDependencies(
139 string $a_entity,
140 string $a_version,
141 ?array $a_rec = null,
142 ?array $a_ids = null
143 ): array {
144 return [];
145 }
146
147
148 public function readData(string $a_entity, string $a_version, array $a_ids): void
149 {
150 $this->data = array();
151 if (!is_array($a_ids)) {
152 $a_ids = array($a_ids);
153 }
154 $this->_readData($a_entity, $a_ids);
155 }
156
157
161 protected function _readData(string $a_entity, array $a_ids): void
162 {
163 switch ($a_entity) {
164 case 'bibl':
165 foreach ($a_ids as $bibl_id) {
166 if (ilObject::_lookupType($bibl_id) === 'bibl') {
167 $obj = new ilObjBibliographic($bibl_id);
168 $data = array(
169 'id' => $bibl_id,
170 'title' => $obj->getTitle(),
171 'description' => $obj->getDescription(),
172 'fileName' => $obj->getFilename(),
173 'is_online' => $obj->getOnline(),
174 );
175 $this->data[] = $data;
176 }
177 }
178 break;
179 default:
180 }
181 }
182
183
184 public function exportLibraryFile(int $a_id): void
185 {
186 $obj = new ilObjBibliographic($a_id);
187 $fileAbsolutePath = $obj->getLegacyAbsolutePath();
188 copy($fileAbsolutePath, $this->absolute_export_dir . "/" . $obj->getFilename());
189 }
190
191
195 public function importLibraryFile(\ilImportMapping $a_mapping): void
196 {
197 $bib_id = $this->import_bib_object->getId();
198 $filename = $this->import_bib_object->getFilename();
199 $import_path = $this->getImportDirectory() . "/Modules/Bibliographic/set_1/expDir_1/" . $filename;
200
201 // create new resource from stream
202 $stream = Streams::ofResource(@fopen($import_path, 'rb'));
203 $identification = $this->storage->manage()->stream($stream, $this->stakeholder, $filename);
204
205 // insert rid of the new resource into the data table
206 $this->db->manipulateF(
207 'UPDATE `il_bibl_data` SET `rid` = %s WHERE `id` = %s;',
208 ['text', 'integer'],
209 [
210 $identification->serialize(),
211 $bib_id,
212 ]
213 );
214 }
215}
$filename
Definition: buildRTE.php:78
Bibliographic dataset class.
importLibraryFile(\ilImportMapping $a_mapping)
ilObjBibliographicStakeholder $stakeholder
_readData(string $a_entity, array $a_ids)
Build data array, data is read from cache except bibl object itself.
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
Return dependencies form entities to other entities (in our case these are all the DB relations)
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
getXmlNamespace(string $a_entity, string $a_schema_version)
getTypes(string $a_entity, string $a_version)
Map XML attributes of entities to datatypes (text, integer...)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
Class ilObjBibliographicStakeholder.
Class ilObjBibliographic.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType(int $id, bool $reference=false)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
Interface Location.
Definition: Location.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc