ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilBlogDataSet Class Reference

Blog Data set class This class implements the following entities: More...

+ Inheritance diagram for ilBlogDataSet:
+ Collaboration diagram for ilBlogDataSet:

Public Member Functions

 __construct ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 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. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text" > <ftype name="field_2" type="date" > <ftype name="field_3" type="integer" > </types> <types ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 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. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Static Public Attributes

static array $style_map = array()
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

InternalService $service
 
SettingsManager $blog_settings
 
ReadingTimeManager $reading_time
 
Service $notes
 
ilObjBlog $current_blog
 
ILIAS Style Content DomainService $content_style_domain
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Detailed Description

Blog Data set class This class implements the following entities:

Definition at line 33 of file class.ilBlogDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilBlogDataSet::__construct ( )

Reimplemented from ilDataSet.

Definition at line 43 of file class.ilBlogDataSet.php.

44 {
45 global $DIC;
47
48 $this->service = $DIC->blog()->internal();
49
50 $this->content_style_domain = $DIC
51 ->contentStyle()
52 ->domain();
53 $this->notes = $DIC->notes();
54 $this->reading_time = $this->service->domain()->readingTime();
55 $this->blog_settings = $this->service->domain()->blogSettings();
56 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilBlogDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Reimplemented from ilDataSet.

Definition at line 301 of file class.ilBlogDataSet.php.

306 : array {
307 if ($a_entity === "blog") {
308 return array(
309 "blog_posting" => array("ids" => $a_rec["Id"] ?? null)
310 );
311 }
312 return [];
313 }

◆ getSupportedVersions()

ilBlogDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

Definition at line 58 of file class.ilBlogDataSet.php.

58 : array
59 {
60 return array("4.3.0", "5.0.0", "5.3.0", "8.0");
61 }

◆ getTypes()

ilBlogDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Get (abstract) types for (abstract) field names.

Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)

Reimplemented from ilDataSet.

Definition at line 75 of file class.ilBlogDataSet.php.

78 : array {
79 if ($a_entity === "blog") {
80 switch ($a_version) {
81 case "4.3.0":
82 return array(
83 "Id" => "integer",
84 "Title" => "text",
85 "Description" => "text",
86 "Notes" => "integer",
87 "BgColor" => "text",
88 "FontColor" => "text",
89 "Img" => "text",
90 "Ppic" => "integer",
91 "RssActive" => "integer",
92 "Approval" => "integer",
93 "Dir" => "directory"
94 );
95
96 case "5.0.0":
97 return array(
98 "Id" => "integer",
99 "Title" => "text",
100 "Description" => "text",
101 "Notes" => "integer",
102 "BgColor" => "text",
103 "FontColor" => "text",
104 "Img" => "text",
105 "Ppic" => "integer",
106 "RssActive" => "integer",
107 "Approval" => "integer",
108 "Dir" => "directory",
109 "AbsShorten" => "integer",
110 "AbsShortenLen" => "integer",
111 "AbsImage" => "integer",
112 "AbsImgWidth" => "integer",
113 "AbsImgHeight" => "integer",
114 "NavMode" => "integer",
115 "NavListPost" => "integer",
116 "NavListMon" => "integer",
117 "Keywords" => "integer",
118 "Authors" => "integer",
119 "NavOrder" => "text",
120 "OvPost" => "integer",
121 "Style" => "integer"
122 );
123
124 case "5.3.0":
125 return array(
126 "Id" => "integer",
127 "Title" => "text",
128 "Description" => "text",
129 "Notes" => "integer",
130 "BgColor" => "text",
131 "FontColor" => "text",
132 "Img" => "text",
133 "Ppic" => "integer",
134 "RssActive" => "integer",
135 "Approval" => "integer",
136 "Dir" => "directory",
137 "AbsShorten" => "integer",
138 "AbsShortenLen" => "integer",
139 "AbsImage" => "integer",
140 "AbsImgWidth" => "integer",
141 "AbsImgHeight" => "integer",
142 "NavMode" => "integer",
143 "NavListMonWithPost" => "integer",
144 "NavListMon" => "integer",
145 "Keywords" => "integer",
146 "Authors" => "integer",
147 "NavOrder" => "text",
148 "OvPost" => "integer",
149 "Style" => "integer"
150 );
151
152 case "8.0":
153 return array(
154 "Id" => "integer",
155 "Title" => "text",
156 "Description" => "text",
157 "Notes" => "integer",
158 "BgColor" => "text",
159 "FontColor" => "text",
160 "Img" => "text",
161 "Ppic" => "integer",
162 "RssActive" => "integer",
163 "Approval" => "integer",
164 "Dir" => "directory",
165 "AbsShorten" => "integer",
166 "AbsShortenLen" => "integer",
167 "AbsImage" => "integer",
168 "AbsImgWidth" => "integer",
169 "AbsImgHeight" => "integer",
170 "NavMode" => "integer",
171 "NavListMonWithPost" => "integer",
172 "NavListMon" => "integer",
173 "Keywords" => "integer",
174 "Authors" => "integer",
175 "NavOrder" => "text",
176 "OvPost" => "integer",
177 "Style" => "integer",
178 "ReadingTime" => "integer"
179 );
180 }
181 }
182
183 if ($a_entity === "blog_posting") {
184 switch ($a_version) {
185 case "4.3.0":
186 case "5.0.0":
187 case "5.3.0":
188 case "8.0":
189 return array(
190 "Id" => "integer",
191 "BlogId" => "integer",
192 "Title" => "integer",
193 "Created" => "text",
194 "Author" => "text",
195 "Approved" => "integer",
196 "LastWithdrawn" => "text"
197 );
198 }
199 }
200 return [];
201 }

◆ getXmlNamespace()

ilBlogDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Reimplemented from ilDataSet.

Definition at line 63 of file class.ilBlogDataSet.php.

66 : string {
67
68 if ($a_entity === 'blog' || $a_entity == 'blog_posting') {
69 // they share the same xsd, therfore the same namespace
70 return "http://www.ilias.de/xml/Modules/Blog/blog";
71 }
72 return "http://www.ilias.de/xml/Modules/Blog/" . $a_entity;
73 }

◆ getXmlRecord()

ilBlogDataSet::getXmlRecord ( string  $a_entity,
string  $a_version,
array  $a_set 
)

Get xml record for version.

Parameters
array$a_setabstract data record

Reimplemented from ilDataSet.

Definition at line 315 of file class.ilBlogDataSet.php.

319 : array {
320 if ($a_entity === "blog") {
321 $style = $this->content_style_domain->styleForObjId((int) $a_set["Id"]);
322
323 $a_set["Style"] = $style->getStyleId();
324
325 // #14734
326 $a_set["Notes"] = $this->notes->domain()->commentsActive((int) $a_set["Id"]);
327 }
328
329 return $a_set;
330 }

◆ importRecord()

ilBlogDataSet::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.

Reimplemented from ilDataSet.

Definition at line 332 of file class.ilBlogDataSet.php.

338 : void {
339 $data = $this->service->data();
340 $a_rec = $this->stripTags($a_rec);
341 switch ($a_entity) {
342 case "blog":
343
344 // container copy
345 if ($new_id = $a_mapping->getMapping("components/ILIAS/Container", "objs", $a_rec["Id"])) {
346 $newObj = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
347 } else {
348 $newObj = new ilObjBlog();
349 $newObj->create();
350 }
351
352 $newObj->setTitle($a_rec["Title"] ?? "");
353 $newObj->setDescription($a_rec["Description"] ?? "");
354 $newObj->setNotesStatus((bool) ($a_rec["Notes"] ?? false));
355 $newObj->update();
356
357 $blog_settings = $data->settings(
358 $newObj->getId(),
359 (bool) ($a_rec["Ppic"] ?? false),
360 $a_rec["BgColor"] ?? "",
361 $a_rec["FontColor"] ?? "",
362 (bool) ($a_rec["RssActive"] ?? false),
363 (bool) ($a_rec["Approval"] ?? false),
364 (bool) ($a_rec["AbsShorten"] ?? false),
365 (int) ($a_rec["AbsShortenLen"] ?? 0),
366 (bool) ($a_rec["AbsImage"] ?? 0),
367 (int) ($a_rec["AbsImgWidth"] ?? 0),
368 (int) ($a_rec["AbsImgHeight"] ?? 0),
369 (bool) ($a_rec["Keywords"] ?? false),
370 (bool) ($a_rec["Authors"] ?? false),
371 (int) ($a_rec["NavMode"] ?? 0),
372 (($a_rec["NavListMonWithPost"] ?? 0) == 0)
373 ? 3
374 : (int) $a_rec["NavListMonWithPost"],
375 (int) ($a_rec["NavListMon"] ?? 3),
376 (int) ($a_rec["OvPost"] ?? null),
377 trim($a_rec["NavOrder"])
378 ? explode(";", $a_rec["NavOrder"])
379 : []
380 );
381 $this->blog_settings->update($blog_settings);
382
383 if ($a_rec["Style"] ?? false) {
384 self::$style_map[$a_rec["Style"]][] = $newObj->getId();
385 }
386
387 // reading time
388 $this->reading_time->activate($newObj->getId(), (bool) ($a_rec["ReadingTime"] ?? false));
389
390 $a_mapping->addMapping("components/ILIAS/Blog", "blog", $a_rec["Id"], (string) $newObj->getId());
391 $a_mapping->addMapping(
392 'components/ILIAS/MetaData',
393 'md',
394 $a_rec["Id"] . ':0:blog',
395 $newObj->getId() . ':0:blog'
396 );
397 break;
398
399 case "blog_posting":
400 $blog_id = (int) $a_mapping->getMapping("components/ILIAS/Blog", "blog", $a_rec["BlogId"]);
401 if ($blog_id) {
402 $newObj = new ilBlogPosting();
403 $newObj->setBlogId($blog_id);
404 $newObj->setTitle($a_rec["Title"] ?? "");
405 $newObj->setCreated(new ilDateTime($a_rec["Created"] ?? null, IL_CAL_DATETIME));
406 $newObj->setApproved((bool) ($a_rec["Approved"] ?? null));
407 $newObj->setWithdrawn(new ilDateTime($a_rec["LastWithdrawn"] ?? null, IL_CAL_DATETIME));
408
409 // parse export id into local id (if possible)
410 $author = $this->parseObjectExportId($a_rec["Author"] ?? "", "-1");
411 $newObj->setAuthor((int) $author["id"]);
412
413 $newObj->create(true);
414
415 // keywords
416 $keywords = array();
417 for ($loop = 0; $loop < 1000; $loop++) {
418 $idx = "Keyword" . $loop;
419 if (isset($a_rec[$idx])) {
420 $keyword = trim($a_rec[$idx]);
421 if ($keyword !== '') {
422 $keywords[] = $keyword;
423 }
424 }
425 }
426 if (count($keywords)) {
427 $newObj->updateKeywords($keywords);
428 }
429
430 $a_mapping->addMapping(
431 "components/ILIAS/COPage",
432 "pg",
433 "blp:" . $a_rec["Id"],
434 "blp:" . $newObj->getId()
435 );
436 }
437 break;
438 }
439 }
const IL_CAL_DATETIME
SettingsManager $blog_settings
Class ilBlogPosting.
stripTags(array $rec, array $omit_keys=[])
parseObjectExportId(string $a_id, ?string $a_fallback_id=null)
Parse export id.
@classDescription Date and time handling
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)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

◆ readData()

ilBlogDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Reimplemented from ilDataSet.

Definition at line 203 of file class.ilBlogDataSet.php.

207 : void {
209
210 if ($a_entity === "blog") {
211 switch ($a_version) {
212 case "4.3.0":
214 "SELECT bl.id,od.title,od.description," .
215 "bl.notes,bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval" .
216 " FROM il_blog bl" .
217 " JOIN object_data od ON (od.obj_id = bl.id)" .
218 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
219 " AND od.type = " . $ilDB->quote("blog", "text")
220 );
221 break;
222
223 case "5.0.0":
225 "SELECT bl.id,od.title,od.description," .
226 "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
227 "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
228 "bl.nav_mode,bl.nav_list_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
229 "bl.ov_post" .
230 " FROM il_blog bl" .
231 " JOIN object_data od ON (od.obj_id = bl.id)" .
232 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
233 " AND od.type = " . $ilDB->quote("blog", "text")
234 );
235 break;
236
237 case "5.3.0":
239 "SELECT bl.id,od.title,od.description," .
240 "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
241 "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
242 "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
243 "bl.ov_post" .
244 " FROM il_blog bl" .
245 " JOIN object_data od ON (od.obj_id = bl.id)" .
246 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
247 " AND od.type = " . $ilDB->quote("blog", "text")
248 );
249 break;
250
251 case "8.0":
253 "SELECT bl.id,od.title,od.description," .
254 "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
255 "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
256 "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
257 "bl.ov_post" .
258 " FROM il_blog bl" .
259 " JOIN object_data od ON (od.obj_id = bl.id)" .
260 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
261 " AND od.type = " . $ilDB->quote("blog", "text")
262 );
263 foreach ($this->data as $idx => $item) {
264 $this->data[$idx]["ReadingTime"] = (int) $this->reading_time->isActivated((int) $item["Id"]);
265 }
266 break;
267 }
268 }
269
270 if ($a_entity === "blog_posting") {
271 switch ($a_version) {
272 case "4.3.0":
273 case "5.0.0":
274 case "5.3.0":
275 case "8.0":
277 "SELECT id,blog_id,title,created,author,approved,last_withdrawn" .
278 " FROM il_blog_posting WHERE " .
279 $ilDB->in("blog_id", $a_ids, false, "integer")
280 );
281 foreach ($this->data as $idx => $item) {
282 // create full export id
283 $this->data[$idx]["Author"] = $this->createObjectExportId("usr", (string) $item["Author"]);
284 }
285 break;
286 }
287
288 // keywords
289 foreach ($this->data as $idx => $item) {
290 $blog_id = $this->service->domain()->posting()->lookupBlogId((int) $item["Id"]);
291 $keywords = $this->service->domain()->posting()->getKeywords((int) $blog_id, (int) $item["Id"]);
292 if ($keywords) {
293 foreach ($keywords as $kidx => $keyword) {
294 $this->data[$idx]["Keyword" . $kidx] = $keyword;
295 }
296 }
297 }
298 }
299 }
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
createObjectExportId(string $a_type, string $a_id)
Build ilias export id.
ilDBInterface $db

References $ilDB, and ILIAS\Repository\int().

+ Here is the call graph for this function:

Field Documentation

◆ $blog_settings

SettingsManager ilBlogDataSet::$blog_settings
protected

Definition at line 36 of file class.ilBlogDataSet.php.

◆ $content_style_domain

ILIAS Style Content DomainService ilBlogDataSet::$content_style_domain
protected

Definition at line 41 of file class.ilBlogDataSet.php.

◆ $current_blog

ilObjBlog ilBlogDataSet::$current_blog
protected

Definition at line 39 of file class.ilBlogDataSet.php.

◆ $notes

Service ilBlogDataSet::$notes
protected

Definition at line 38 of file class.ilBlogDataSet.php.

◆ $reading_time

ReadingTimeManager ilBlogDataSet::$reading_time
protected

Definition at line 37 of file class.ilBlogDataSet.php.

◆ $service

InternalService ilBlogDataSet::$service
protected

Definition at line 35 of file class.ilBlogDataSet.php.

◆ $style_map

array ilBlogDataSet::$style_map = array()
static

Definition at line 40 of file class.ilBlogDataSet.php.


The documentation for this class was generated from the following file: