ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- 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...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 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 ...> ... 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)
 

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)
 
 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)
 
 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

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 $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

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 31 of file class.ilBlogDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilBlogDataSet::__construct ( )

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

References $DIC, and ILIAS\MetaData\Repository\Validation\Data\__construct().

40  {
41  global $DIC;
43  $this->content_style_domain = $DIC
44  ->contentStyle()
45  ->domain();
46  $this->notes = $DIC->notes();
47  $this->reading_time = $DIC->blog()->internal()->domain()->readingTime();
48  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ 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

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

298  : array {
299  if ($a_entity === "blog") {
300  return array(
301  "blog_posting" => array("ids" => $a_rec["Id"] ?? null)
302  );
303  }
304  return [];
305  }

◆ getSupportedVersions()

ilBlogDataSet::getSupportedVersions ( )

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

50  : array
51  {
52  return array("4.3.0", "5.0.0", "5.3.0", "8.0");
53  }

◆ getTypes()

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

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

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

◆ getXmlNamespace()

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

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

58  : string {
59 
60  if ($a_entity === 'blog' || $a_entity == 'blog_posting') {
61  // they share the same xsd, therfore the same namespace
62  return "http://www.ilias.de/xml/Modules/Blog/blog";
63  }
64  return "http://www.ilias.de/xml/Modules/Blog/" . $a_entity;
65  }

◆ getXmlRecord()

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

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

References ilObjBlog\initStorage().

311  : array {
312  if ($a_entity === "blog") {
313  $style = $this->content_style_domain->styleForObjId((int) $a_set["Id"]);
314 
315  $dir = ilObjBlog::initStorage($a_set["Id"]);
316  $a_set["Dir"] = $dir;
317 
318  $a_set["Style"] = $style->getStyleId();
319 
320  // #14734
321  $a_set["Notes"] = $this->notes->domain()->commentsActive((int) $a_set["Id"]);
322  }
323 
324  return $a_set;
325  }
static initStorage(int $a_id, string $a_subdir=null)
Init file system storage.
+ Here is the call graph for this function:

◆ importRecord()

ilBlogDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

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

References ilImportMapping\addMapping(), ilDataSet\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilImportMapping\getMapping(), IL_CAL_DATETIME, ilObjBlog\initStorage(), ILIAS\Repository\int(), ilDataSet\parseObjectExportId(), ilFileUtils\rCopy(), and ilDataSet\stripTags().

333  : void {
334  $a_rec = $this->stripTags($a_rec);
335  switch ($a_entity) {
336  case "blog":
337 
338  // container copy
339  if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
340  $newObj = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
341  } else {
342  $newObj = new ilObjBlog();
343  $newObj->create();
344  }
345 
346  $newObj->setTitle($a_rec["Title"] ?? "");
347  $newObj->setDescription($a_rec["Description"] ?? "");
348  $newObj->setNotesStatus((bool) ($a_rec["Notes"] ?? false));
349  $newObj->setBackgroundColor($a_rec["BgColor"] ?? "");
350  $newObj->setFontColor($a_rec["FontColor"] ?? "");
351  $newObj->setProfilePicture((bool) ($a_rec["Ppic"] ?? false));
352  $newObj->setRSS((bool) ($a_rec["RssActive"] ?? false));
353  $newObj->setApproval((bool) ($a_rec["Approval"] ?? false));
354  $newObj->setImage($a_rec["Img"] ?? "");
355 
356  $newObj->setAbstractShorten((bool) ($a_rec["AbsShorten"] ?? false));
357  $newObj->setAbstractShortenLength((int) ($a_rec["AbsShortenLen"] ?? 0));
358  $newObj->setAbstractImage((bool) ($a_rec["AbsImage"] ?? 0));
359  $newObj->setAbstractImageWidth((int) ($a_rec["AbsImgWidth"] ?? 0));
360  $newObj->setAbstractImageHeight((int) ($a_rec["AbsImgHeight"] ?? 0));
361  $newObj->setNavMode((int) ($a_rec["NavMode"] ?? 0));
362  if (($a_rec["NavListMonWithPost"] ?? 0) == 0) {
363  $newObj->setNavModeListMonthsWithPostings(3);
364  } else {
365  $newObj->setNavModeListMonthsWithPostings((int) $a_rec["NavListMonWithPost"]);
366  }
367  //$newObj->setNavModeListPostings($a_rec["NavListPost"]);
368  if (($nav_list_months = $a_rec["NavListMon"] ?? null) !== null) {
369  $nav_list_months = (int) $nav_list_months;
370  }
371  $newObj->setNavModeListMonths($nav_list_months);
372  $newObj->setKeywords((bool) ($a_rec["Keywords"] ?? false));
373  $newObj->setAuthors((bool) ($a_rec["Authors"] ?? false));
374  $newObj->setOrder(
375  trim($a_rec["NavOrder"])
376  ? explode(";", $a_rec["NavOrder"])
377  : []
378  );
379  if (($ov_post = $a_rec["OvPost"] ?? null) !== null) {
380  $ov_post = (int) $ov_post;
381  }
382  $newObj->setOverviewPostings($ov_post);
383 
384  $newObj->update();
385 
386  // handle image(s)
387  if ($a_rec["Img"] ?? false) {
388  $dir = str_replace("..", "", $a_rec["Dir"]);
389  if ($dir !== "" && $this->getImportDirectory() !== "") {
390  $source_dir = $this->getImportDirectory() . "/" . $dir;
391  $target_dir = ilObjBlog::initStorage($newObj->getId());
392  ilFileUtils::rCopy($source_dir, $target_dir);
393  }
394  }
395 
396  if ($a_rec["Style"] ?? false) {
397  self::$style_map[$a_rec["Style"]][] = $newObj->getId();
398  }
399 
400  // reading time
401  $this->reading_time->activate($newObj->getId(), (bool) ($a_rec["ReadingTime"] ?? false));
402 
403  $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], (string) $newObj->getId());
404  break;
405 
406  case "blog_posting":
407  $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
408  if ($blog_id) {
409  $newObj = new ilBlogPosting();
410  $newObj->setBlogId($blog_id);
411  $newObj->setTitle($a_rec["Title"] ?? "");
412  $newObj->setCreated(new ilDateTime($a_rec["Created"] ?? null, IL_CAL_DATETIME));
413  $newObj->setApproved((bool) ($a_rec["Approved"] ?? null));
414  $newObj->setWithdrawn(new ilDateTime($a_rec["LastWithdrawn"] ?? null, IL_CAL_DATETIME));
415 
416  // parse export id into local id (if possible)
417  $author = $this->parseObjectExportId($a_rec["Author"] ?? "", "-1");
418  $newObj->setAuthor((int) $author["id"]);
419 
420  $newObj->create(true);
421 
422  // keywords
423  $keywords = array();
424  for ($loop = 0; $loop < 1000; $loop++) {
425  $idx = "Keyword" . $loop;
426  if (isset($a_rec[$idx])) {
427  $keyword = trim($a_rec[$idx]);
428  if ($keyword !== '') {
429  $keywords[] = $keyword;
430  }
431  }
432  }
433  if (count($keywords)) {
434  $newObj->updateKeywords($keywords);
435  }
436 
437  $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
438  }
439  break;
440  }
441  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_DATETIME
parseObjectExportId(string $a_id, ?string $a_fallback_id=null)
Parse export id.
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
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 initStorage(int $a_id, string $a_subdir=null)
Init file system storage.
Class ilObjBlog.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
stripTags(array $rec, array $omit_keys=[])
+ Here is the call graph for this function:

◆ readData()

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

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

References ilDataSet\$db, $ilDB, ilDataSet\createObjectExportId(), ilDataSet\getDirectDataFromQuery(), ilBlogPosting\getKeywords(), ILIAS\Repository\int(), and ilBlogPosting\lookupBlogId().

199  : void {
200  $ilDB = $this->db;
201 
202  if ($a_entity === "blog") {
203  switch ($a_version) {
204  case "4.3.0":
205  $this->getDirectDataFromQuery(
206  "SELECT bl.id,od.title,od.description," .
207  "bl.notes,bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval" .
208  " FROM il_blog bl" .
209  " JOIN object_data od ON (od.obj_id = bl.id)" .
210  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
211  " AND od.type = " . $ilDB->quote("blog", "text")
212  );
213  break;
214 
215  case "5.0.0":
216  $this->getDirectDataFromQuery(
217  "SELECT bl.id,od.title,od.description," .
218  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
219  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
220  "bl.nav_mode,bl.nav_list_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
221  "bl.ov_post" .
222  " FROM il_blog bl" .
223  " JOIN object_data od ON (od.obj_id = bl.id)" .
224  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
225  " AND od.type = " . $ilDB->quote("blog", "text")
226  );
227  break;
228 
229  case "5.3.0":
230  $this->getDirectDataFromQuery(
231  "SELECT bl.id,od.title,od.description," .
232  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
233  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
234  "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
235  "bl.ov_post" .
236  " FROM il_blog bl" .
237  " JOIN object_data od ON (od.obj_id = bl.id)" .
238  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
239  " AND od.type = " . $ilDB->quote("blog", "text")
240  );
241  break;
242 
243  case "8.0":
244  $this->getDirectDataFromQuery(
245  "SELECT bl.id,od.title,od.description," .
246  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
247  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
248  "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
249  "bl.ov_post" .
250  " FROM il_blog bl" .
251  " JOIN object_data od ON (od.obj_id = bl.id)" .
252  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
253  " AND od.type = " . $ilDB->quote("blog", "text")
254  );
255  foreach ($this->data as $idx => $item) {
256  $this->data[$idx]["ReadingTime"] = (int) $this->reading_time->isActivated((int) $item["Id"]);
257  }
258  break;
259  }
260  }
261 
262  if ($a_entity === "blog_posting") {
263  switch ($a_version) {
264  case "4.3.0":
265  case "5.0.0":
266  case "5.3.0":
267  case "8.0":
268  $this->getDirectDataFromQuery(
269  "SELECT id,blog_id,title,created,author,approved,last_withdrawn" .
270  " FROM il_blog_posting WHERE " .
271  $ilDB->in("blog_id", $a_ids, false, "integer")
272  );
273  foreach ($this->data as $idx => $item) {
274  // create full export id
275  $this->data[$idx]["Author"] = $this->createObjectExportId("usr", (string) $item["Author"]);
276  }
277  break;
278  }
279 
280  // keywords
281  foreach ($this->data as $idx => $item) {
282  $blog_id = ilBlogPosting::lookupBlogId($item["Id"]);
283  $keywords = ilBlogPosting::getKeywords($blog_id, $item["Id"]);
284  if ($keywords) {
285  foreach ($keywords as $kidx => $keyword) {
286  $this->data[$idx]["Keyword" . $kidx] = $keyword;
287  }
288  }
289  }
290  }
291  }
createObjectExportId(string $a_type, string $a_id)
Build ilias export id.
ilDBInterface $db
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 ...
static lookupBlogId(int $a_posting_id)
static getKeywords(int $a_obj_id, int $a_posting_id)
+ Here is the call graph for this function:

Field Documentation

◆ $content_style_domain

ILIAS Style Content DomainService ilBlogDataSet::$content_style_domain
protected

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

◆ $current_blog

ilObjBlog ilBlogDataSet::$current_blog
protected

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

◆ $notes

Service ilBlogDataSet::$notes
protected

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

◆ $reading_time

ReadingTimeManager ilBlogDataSet::$reading_time
protected

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

◆ $style_map

array ilBlogDataSet::$style_map = array()
static

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

Referenced by ilBlogImporter\finalProcessing().


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