ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBlogDataSet Class Reference

Blog Data set class. More...

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

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $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 ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Static Public Attributes

static $style_map = array()
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

 $current_blog
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 
 $ds_namespace = 'ds'
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
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
 

Detailed Description

Blog Data set class.

This class implements the following entities:

  • blog: object data
  • blog_posting: data from table il_blog_posting
Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Member Function Documentation

◆ getDependencies()

ilBlogDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

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

218  {
219  switch ($a_entity) {
220  case "blog":
221  return array(
222  "blog_posting" => array("ids" => $a_rec["Id"])
223  );
224  }
225  return false;
226  }

◆ getSupportedVersions()

ilBlogDataSet::getSupportedVersions ( )

Get supported versions.

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

24  {
25  return array("4.3.0", "5.0.0", "5.3.0");
26  }

◆ getTypes()

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

Get field types for entity.

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

40  {
41  if ($a_entity == "blog") {
42  switch ($a_version) {
43  case "4.3.0":
44  return array(
45  "Id" => "integer",
46  "Title" => "text",
47  "Description" => "text",
48  "Notes" => "integer",
49  "BgColor" => "text",
50  "FontColor" => "text",
51  "Img" => "text",
52  "Ppic" => "integer",
53  "RssActive" => "integer",
54  "Approval" => "integer",
55  "Dir" => "directory"
56  );
57 
58  case "5.0.0":
59  return array(
60  "Id" => "integer",
61  "Title" => "text",
62  "Description" => "text",
63  "Notes" => "integer",
64  "BgColor" => "text",
65  "FontColor" => "text",
66  "Img" => "text",
67  "Ppic" => "integer",
68  "RssActive" => "integer",
69  "Approval" => "integer",
70  "Dir" => "directory",
71  "AbsShorten" => "integer",
72  "AbsShortenLen" => "integer",
73  "AbsImage" => "integer",
74  "AbsImgWidth" => "integer",
75  "AbsImgHeight" => "integer",
76  "NavMode" => "integer",
77  "NavListPost" => "integer",
78  "NavListMon" => "integer",
79  "Keywords" => "integer",
80  "Authors" => "integer",
81  "NavOrder" => "text",
82  "OvPost" => "integer",
83  "Style" => "integer"
84  );
85 
86  case "5.3.0":
87  return array(
88  "Id" => "integer",
89  "Title" => "text",
90  "Description" => "text",
91  "Notes" => "integer",
92  "BgColor" => "text",
93  "FontColor" => "text",
94  "Img" => "text",
95  "Ppic" => "integer",
96  "RssActive" => "integer",
97  "Approval" => "integer",
98  "Dir" => "directory",
99  "AbsShorten" => "integer",
100  "AbsShortenLen" => "integer",
101  "AbsImage" => "integer",
102  "AbsImgWidth" => "integer",
103  "AbsImgHeight" => "integer",
104  "NavMode" => "integer",
105  "NavListMonWithPost" => "integer",
106  "NavListMon" => "integer",
107  "Keywords" => "integer",
108  "Authors" => "integer",
109  "NavOrder" => "text",
110  "OvPost" => "integer",
111  "Style" => "integer"
112  );
113 
114  }
115  }
116 
117  if ($a_entity == "blog_posting") {
118  switch ($a_version) {
119  case "4.3.0":
120  case "5.0.0":
121  case "5.3.0":
122  return array(
123  "Id" => "integer",
124  "BlogId" => "integer",
125  "Title" => "integer",
126  "Created" => "text",
127  "Author" => "text",
128  "Approved" => "integer",
129  "LastWithdrawn" => "text"
130  );
131  }
132  }
133  }

◆ getXmlNamespace()

ilBlogDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

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

32  {
33  return "http://www.ilias.de/xml/Modules/Blog/" . $a_entity;
34  }

◆ getXmlRecord()

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

Get xml record.

Parameters

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

References ilNote\commentsActivated(), ilObjBlog\initStorage(), and ilObjStyleSheet\lookupObjectStyle().

235  {
236  if ($a_entity == "blog") {
237  $dir = ilObjBlog::initStorage($a_set["Id"]);
238  $a_set["Dir"] = $dir;
239 
240  $a_set["Style"] = ilObjStyleSheet::lookupObjectStyle($a_set["Id"]);
241 
242  // #14734
243  $a_set["Notes"] = ilNote::commentsActivated($a_set["Id"], 0, "blog");
244  }
245 
246  return $a_set;
247  }
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
static lookupObjectStyle($a_obj_id)
Lookup object style.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
+ Here is the call graph for this function:

◆ importRecord()

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

Import record.

Parameters

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

References ilDataSet\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), IL_CAL_DATETIME, ilObjBlog\initStorage(), ilDataSet\parseObjectExportId(), ilUtil\rCopy(), and ilDataSet\stripTags().

256  {
257  $a_rec = $this->stripTags($a_rec);
258  switch ($a_entity) {
259  case "blog":
260 
261  // container copy
262  if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
263  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
264  } else {
265  $newObj = new ilObjBlog();
266  $newObj->create();
267  }
268 
269  $newObj->setTitle($a_rec["Title"]);
270  $newObj->setDescription($a_rec["Description"]);
271  $newObj->setNotesStatus($a_rec["Notes"]);
272  $newObj->setBackgroundColor($a_rec["BgColor"]);
273  $newObj->setFontColor($a_rec["FontColor"]);
274  $newObj->setProfilePicture($a_rec["Ppic"]);
275  $newObj->setRSS($a_rec["RssActive"]);
276  $newObj->setApproval($a_rec["Approval"]);
277  $newObj->setImage($a_rec["Img"]);
278 
279  $newObj->setAbstractShorten($a_rec["AbsShorten"]);
280  $newObj->setAbstractShortenLength($a_rec["AbsShortenLen"]);
281  $newObj->setAbstractImage($a_rec["AbsImage"]);
282  $newObj->setAbstractImageWidth($a_rec["AbsImgWidth"]);
283  $newObj->setAbstractImageHeight($a_rec["AbsImgHeight"]);
284  $newObj->setNavMode($a_rec["NavMode"]);
285  if ($a_rec["NavListMonWithPost"] == 0) {
286  $newObj->setNavModeListMonthsWithPostings(3);
287  } else {
288  $newObj->setNavModeListMonthsWithPostings($a_rec["NavListMonWithPost"]);
289  }
290  //$newObj->setNavModeListPostings($a_rec["NavListPost"]);
291  $newObj->setNavModeListMonths($a_rec["NavListMon"]);
292  $newObj->setKeywords($a_rec["Keywords"]);
293  $newObj->setAuthors($a_rec["Authors"]);
294  $newObj->setOrder(trim($a_rec["NavOrder"])
295  ? explode(";", $a_rec["NavOrder"])
296  : null);
297  $newObj->setOverviewPostings($a_rec["OvPost"]);
298 
299  $newObj->update();
300 
301  // handle image(s)
302  if ($a_rec["Img"]) {
303  $dir = str_replace("..", "", $a_rec["Dir"]);
304  if ($dir != "" && $this->getImportDirectory() != "") {
305  $source_dir = $this->getImportDirectory() . "/" . $dir;
306  $target_dir = ilObjBlog::initStorage($newObj->getId());
307  ilUtil::rCopy($source_dir, $target_dir);
308  }
309  }
310 
311  if ($a_rec["Style"]) {
312  self::$style_map[$a_rec["Style"]][] = $newObj->getId();
313  }
314  $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
315  break;
316 
317  case "blog_posting":
318  $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
319  if ($blog_id) {
320  $newObj = new ilBlogPosting();
321  $newObj->setBlogId($blog_id);
322  $newObj->setTitle($a_rec["Title"]);
323  $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME));
324  $newObj->setApproved($a_rec["Approved"]);
325  $newObj->setWithdrawn(new ilDateTime($a_rec["LastWithdrawn"], IL_CAL_DATETIME));
326 
327  // parse export id into local id (if possible)
328  $author = $this->parseObjectExportId($a_rec["Author"], -1);
329  $newObj->setAuthor($author["id"]);
330 
331  $newObj->create(true);
332 
333  // keywords
334  $keywords = array();
335  for ($loop = 0; $loop < 1000; $loop++) {
336  if (isset($a_rec["Keyword" . $loop])) {
337  $keyword = trim($a_rec["Keyword" . $loop]);
338  if (strlen($keyword)) {
339  $keywords[] = $keyword;
340  }
341  }
342  }
343  if (sizeof($keywords)) {
344  $newObj->updateKeywords($keywords);
345  }
346 
347  $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
348  }
349  break;
350  }
351  }
Class ilBlogPosting.
const IL_CAL_DATETIME
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getImportDirectory()
Get import directory.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
Class ilObjBlog.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
parseObjectExportId($a_id, $a_fallback_id=null)
Parse export id.
stripTags(array $rec, array $omit_keys=[])
+ Here is the call graph for this function:

◆ readData()

ilBlogDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

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

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

142  {
143  $ilDB = $this->db;
144 
145  if (!is_array($a_ids)) {
146  $a_ids = array($a_ids);
147  }
148 
149  if ($a_entity == "blog") {
150  switch ($a_version) {
151  case "4.3.0":
152  $this->getDirectDataFromQuery("SELECT bl.id,od.title,od.description," .
153  "bl.notes,bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval" .
154  " FROM il_blog bl" .
155  " JOIN object_data od ON (od.obj_id = bl.id)" .
156  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
157  " AND od.type = " . $ilDB->quote("blog", "text"));
158  break;
159 
160  case "5.0.0":
161  $this->getDirectDataFromQuery("SELECT bl.id,od.title,od.description," .
162  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
163  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
164  "bl.nav_mode,bl.nav_list_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
165  "bl.ov_post" .
166  " FROM il_blog bl" .
167  " JOIN object_data od ON (od.obj_id = bl.id)" .
168  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
169  " AND od.type = " . $ilDB->quote("blog", "text"));
170  break;
171 
172  case "5.3.0":
173  $this->getDirectDataFromQuery("SELECT bl.id,od.title,od.description," .
174  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
175  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
176  "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
177  "bl.ov_post" .
178  " FROM il_blog bl" .
179  " JOIN object_data od ON (od.obj_id = bl.id)" .
180  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
181  " AND od.type = " . $ilDB->quote("blog", "text"));
182  break;
183  }
184  }
185 
186  if ($a_entity == "blog_posting") {
187  switch ($a_version) {
188  case "4.3.0":
189  case "5.0.0":
190  case "5.3.0":
191  $this->getDirectDataFromQuery("SELECT id,blog_id,title,created,author,approved,last_withdrawn" .
192  " FROM il_blog_posting WHERE " .
193  $ilDB->in("blog_id", $a_ids, false, "integer"));
194  foreach ($this->data as $idx => $item) {
195  // create full export id
196  $this->data[$idx]["Author"] = $this->createObjectExportId("usr", $item["Author"]);
197  }
198  break;
199  }
200 
201  // keywords
202  foreach ($this->data as $idx => $item) {
203  $blog_id = ilBlogPosting::lookupBlogId($item["Id"]);
204  $keywords = ilBlogPosting::getKeywords($blog_id, $item["Id"]);
205  if ($keywords) {
206  foreach ($keywords as $kidx => $keyword) {
207  $this->data[$idx]["Keyword" . $kidx] = $keyword;
208  }
209  }
210  }
211  }
212  }
static lookupBlogId($a_posting_id)
Lookup blog id.
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
createObjectExportId($a_type, $a_id)
Build ilias export id.
static getKeywords($a_obj_id, $a_posting_id)
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $current_blog

ilBlogDataSet::$current_blog
protected

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

◆ $style_map

ilBlogDataSet::$style_map = array()
static

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

Referenced by ilBlogImporter\finalProcessing().


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