ILIAS  release_8 Revision v8.24
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...
 
 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 ...> ... </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...
 

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

Service $notes
 
ilObjBlog $current_blog
 
ILIAS Style Content DomainService $content_style_domain
 
- Protected Attributes inherited from ilDataSet
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 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 28 of file class.ilBlogDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilBlogDataSet::__construct ( )

Reimplemented from ilDataSet.

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

36 {
37 global $DIC;
39 $this->content_style_domain = $DIC
40 ->contentStyle()
41 ->domain();
42 $this->notes = $DIC->notes();
43 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

241 : array {
242 if ($a_entity === "blog") {
243 return array(
244 "blog_posting" => array("ids" => $a_rec["Id"] ?? null)
245 );
246 }
247 return [];
248 }

◆ getSupportedVersions()

ilBlogDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

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

45 : array
46 {
47 return array("4.3.0", "5.0.0", "5.3.0");
48 }

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

60 : array {
61 if ($a_entity === "blog") {
62 switch ($a_version) {
63 case "4.3.0":
64 return array(
65 "Id" => "integer",
66 "Title" => "text",
67 "Description" => "text",
68 "Notes" => "integer",
69 "BgColor" => "text",
70 "FontColor" => "text",
71 "Img" => "text",
72 "Ppic" => "integer",
73 "RssActive" => "integer",
74 "Approval" => "integer",
75 "Dir" => "directory"
76 );
77
78 case "5.0.0":
79 return array(
80 "Id" => "integer",
81 "Title" => "text",
82 "Description" => "text",
83 "Notes" => "integer",
84 "BgColor" => "text",
85 "FontColor" => "text",
86 "Img" => "text",
87 "Ppic" => "integer",
88 "RssActive" => "integer",
89 "Approval" => "integer",
90 "Dir" => "directory",
91 "AbsShorten" => "integer",
92 "AbsShortenLen" => "integer",
93 "AbsImage" => "integer",
94 "AbsImgWidth" => "integer",
95 "AbsImgHeight" => "integer",
96 "NavMode" => "integer",
97 "NavListPost" => "integer",
98 "NavListMon" => "integer",
99 "Keywords" => "integer",
100 "Authors" => "integer",
101 "NavOrder" => "text",
102 "OvPost" => "integer",
103 "Style" => "integer"
104 );
105
106 case "5.3.0":
107 return array(
108 "Id" => "integer",
109 "Title" => "text",
110 "Description" => "text",
111 "Notes" => "integer",
112 "BgColor" => "text",
113 "FontColor" => "text",
114 "Img" => "text",
115 "Ppic" => "integer",
116 "RssActive" => "integer",
117 "Approval" => "integer",
118 "Dir" => "directory",
119 "AbsShorten" => "integer",
120 "AbsShortenLen" => "integer",
121 "AbsImage" => "integer",
122 "AbsImgWidth" => "integer",
123 "AbsImgHeight" => "integer",
124 "NavMode" => "integer",
125 "NavListMonWithPost" => "integer",
126 "NavListMon" => "integer",
127 "Keywords" => "integer",
128 "Authors" => "integer",
129 "NavOrder" => "text",
130 "OvPost" => "integer",
131 "Style" => "integer"
132 );
133
134 }
135 }
136
137 if ($a_entity === "blog_posting") {
138 switch ($a_version) {
139 case "4.3.0":
140 case "5.0.0":
141 case "5.3.0":
142 return array(
143 "Id" => "integer",
144 "BlogId" => "integer",
145 "Title" => "integer",
146 "Created" => "text",
147 "Author" => "text",
148 "Approved" => "integer",
149 "LastWithdrawn" => "text"
150 );
151 }
152 }
153 return [];
154 }

◆ getXmlNamespace()

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

Reimplemented from ilDataSet.

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

53 : string {
54 return "https://www.ilias.de/xml/Modules/Blog/" . $a_entity;
55 }

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

254 : array {
255 if ($a_entity === "blog") {
256 $style = $this->content_style_domain->styleForObjId((int) $a_set["Id"]);
257
258 $dir = ilObjBlog::initStorage($a_set["Id"]);
259 $a_set["Dir"] = $dir;
260
261 $a_set["Style"] = $style->getStyleId();
262
263 // #14734
264 $a_set["Notes"] = $this->notes->domain()->commentsActive((int) $a_set["Id"]);
265 }
266
267 return $a_set;
268 }
static initStorage(int $a_id, string $a_subdir=null)
Init file system storage.

References ilObjBlog\initStorage().

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

Needs to be overwritten for import use case.

Reimplemented from ilDataSet.

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

276 : void {
277 $a_rec = $this->stripTags($a_rec);
278 switch ($a_entity) {
279 case "blog":
280
281 // container copy
282 if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
283 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
284 } else {
285 $newObj = new ilObjBlog();
286 $newObj->create();
287 }
288
289 $newObj->setTitle($a_rec["Title"] ?? "");
290 $newObj->setDescription($a_rec["Description"] ?? "");
291 $newObj->setNotesStatus((bool) ($a_rec["Notes"] ?? false));
292 $newObj->setBackgroundColor($a_rec["BgColor"] ?? "");
293 $newObj->setFontColor($a_rec["FontColor"] ?? "");
294 $newObj->setProfilePicture((bool) ($a_rec["Ppic"] ?? false));
295 $newObj->setRSS((bool) ($a_rec["RssActive"] ?? false));
296 $newObj->setApproval((bool) ($a_rec["Approval"] ?? false));
297 $newObj->setImage($a_rec["Img"] ?? "");
298
299 $newObj->setAbstractShorten((bool) ($a_rec["AbsShorten"] ?? false));
300 $newObj->setAbstractShortenLength((int) ($a_rec["AbsShortenLen"] ?? 0));
301 $newObj->setAbstractImage((int) ($a_rec["AbsImage"] ?? 0));
302 $newObj->setAbstractImageWidth((int) ($a_rec["AbsImgWidth"] ?? 0));
303 $newObj->setAbstractImageHeight((int) ($a_rec["AbsImgHeight"] ?? 0));
304 $newObj->setNavMode((int) ($a_rec["NavMode"] ?? 0));
305 if (($a_rec["NavListMonWithPost"] ?? 0) == 0) {
306 $newObj->setNavModeListMonthsWithPostings(3);
307 } else {
308 $newObj->setNavModeListMonthsWithPostings((int) $a_rec["NavListMonWithPost"]);
309 }
310 //$newObj->setNavModeListPostings($a_rec["NavListPost"]);
311 if (($nav_list_months = $a_rec["NavListMon"] ?? null) !== null) {
312 $nav_list_months = (int) $nav_list_months;
313 }
314 $newObj->setNavModeListMonths($nav_list_months);
315 $newObj->setKeywords((bool) ($a_rec["Keywords"] ?? false));
316 $newObj->setAuthors((bool) ($a_rec["Authors"] ?? false));
317 $newObj->setOrder(
318 trim($a_rec["NavOrder"])
319 ? explode(";", $a_rec["NavOrder"])
320 : []
321 );
322 if (($ov_post = $a_rec["OvPost"] ?? null) !== null) {
323 $ov_post = (int) $ov_post;
324 }
325 $newObj->setOverviewPostings($ov_post);
326
327 $newObj->update();
328
329 // handle image(s)
330 if ($a_rec["Img"] ?? false) {
331 $dir = str_replace("..", "", $a_rec["Dir"]);
332 if ($dir !== "" && $this->getImportDirectory() !== "") {
333 $source_dir = $this->getImportDirectory() . "/" . $dir;
334 $target_dir = ilObjBlog::initStorage($newObj->getId());
335 ilFileUtils::rCopy($source_dir, $target_dir);
336 }
337 }
338
339 if ($a_rec["Style"] ?? false) {
340 self::$style_map[$a_rec["Style"]][] = $newObj->getId();
341 }
342 $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
343 break;
344
345 case "blog_posting":
346 $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
347 if ($blog_id) {
348 $newObj = new ilBlogPosting();
349 $newObj->setBlogId($blog_id);
350 $newObj->setTitle($a_rec["Title"] ?? "");
351 $newObj->setCreated(new ilDateTime($a_rec["Created"] ?? null, IL_CAL_DATETIME));
352 $newObj->setApproved($a_rec["Approved"] ?? null);
353 $newObj->setWithdrawn(new ilDateTime($a_rec["LastWithdrawn"] ?? null, IL_CAL_DATETIME));
354
355 // parse export id into local id (if possible)
356 $author = $this->parseObjectExportId($a_rec["Author"] ?? "", -1);
357 $newObj->setAuthor((int) $author["id"]);
358
359 $newObj->create(true);
360
361 // keywords
362 $keywords = array();
363 for ($loop = 0; $loop < 1000; $loop++) {
364 $idx = "Keyword" . $loop;
365 if (isset($a_rec[$idx])) {
366 $keyword = trim($a_rec[$idx]);
367 if ($keyword !== '') {
368 $keywords[] = $keyword;
369 }
370 }
371 }
372 if (count($keywords)) {
373 $newObj->updateKeywords($keywords);
374 }
375
376 $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
377 }
378 break;
379 }
380 }
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
stripTags(array $rec, array $omit_keys=[])
parseObjectExportId(string $a_id, ?string $a_fallback_id=null)
Parse export id.
@classDescription Date and time handling
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

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

+ Here is the call graph for this function:

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

160 : void {
162
163 if ($a_entity === "blog") {
164 switch ($a_version) {
165 case "4.3.0":
167 "SELECT bl.id,od.title,od.description," .
168 "bl.notes,bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval" .
169 " FROM il_blog bl" .
170 " JOIN object_data od ON (od.obj_id = bl.id)" .
171 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
172 " AND od.type = " . $ilDB->quote("blog", "text")
173 );
174 break;
175
176 case "5.0.0":
178 "SELECT bl.id,od.title,od.description," .
179 "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
180 "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
181 "bl.nav_mode,bl.nav_list_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
182 "bl.ov_post" .
183 " FROM il_blog bl" .
184 " JOIN object_data od ON (od.obj_id = bl.id)" .
185 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
186 " AND od.type = " . $ilDB->quote("blog", "text")
187 );
188 break;
189
190 case "5.3.0":
192 "SELECT bl.id,od.title,od.description," .
193 "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
194 "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
195 "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
196 "bl.ov_post" .
197 " FROM il_blog bl" .
198 " JOIN object_data od ON (od.obj_id = bl.id)" .
199 " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
200 " AND od.type = " . $ilDB->quote("blog", "text")
201 );
202 break;
203 }
204 }
205
206 if ($a_entity === "blog_posting") {
207 switch ($a_version) {
208 case "4.3.0":
209 case "5.0.0":
210 case "5.3.0":
212 "SELECT id,blog_id,title,created,author,approved,last_withdrawn" .
213 " FROM il_blog_posting WHERE " .
214 $ilDB->in("blog_id", $a_ids, false, "integer")
215 );
216 foreach ($this->data as $idx => $item) {
217 // create full export id
218 $this->data[$idx]["Author"] = $this->createObjectExportId("usr", $item["Author"]);
219 }
220 break;
221 }
222
223 // keywords
224 foreach ($this->data as $idx => $item) {
225 $blog_id = ilBlogPosting::lookupBlogId($item["Id"]);
226 $keywords = ilBlogPosting::getKeywords($blog_id, $item["Id"]);
227 if ($keywords) {
228 foreach ($keywords as $kidx => $keyword) {
229 $this->data[$idx]["Keyword" . $kidx] = $keyword;
230 }
231 }
232 }
233 }
234 }
static lookupBlogId(int $a_posting_id)
static getKeywords(int $a_obj_id, int $a_posting_id)
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.

Field Documentation

◆ $content_style_domain

ILIAS Style Content DomainService ilBlogDataSet::$content_style_domain
protected

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

◆ $current_blog

ilObjBlog ilBlogDataSet::$current_blog
protected

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

◆ $notes

Service ilBlogDataSet::$notes
protected

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

◆ $style_map

array ilBlogDataSet::$style_map = array()
static

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


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