ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $this->content_style_domain = $DIC
48 ->contentStyle()
49 ->domain();
50 $this->notes = $DIC->notes();
51 $this->reading_time = $DIC->blog()->internal()->domain()->readingTime();
52 $this->blog_settings = $DIC->blog()->internal()->domain()->blogSettings();
53 $this->service = $DIC->blog()->internal();
54 }
__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 299 of file class.ilBlogDataSet.php.

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

◆ getSupportedVersions()

ilBlogDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

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

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

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

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

◆ getXmlNamespace()

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

Reimplemented from ilDataSet.

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

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

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

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

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

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

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