ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

Protected Attributes

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

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
Version
$Id$

Definition at line 17 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 221 of file class.ilBlogDataSet.php.

References array.

222  {
223  switch ($a_entity) {
224  case "blog":
225  return array(
226  "blog_posting" => array("ids" => $a_rec["Id"])
227  );
228  }
229  return false;
230  }
Create styles array
The data for the language used.

◆ getSupportedVersions()

ilBlogDataSet::getSupportedVersions ( )

Get supported versions.

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

References array.

27  {
28  return array("4.3.0", "5.0.0", "5.3.0");
29  }
Create styles array
The data for the language used.

◆ getTypes()

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

Get field types for entity.

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

References array.

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

◆ getXmlNamespace()

ilBlogDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

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

35  {
36  return "http://www.ilias.de/xml/Modules/Blog/" . $a_entity;
37  }

◆ getXmlRecord()

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

Get xml record.

Parameters

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

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

239  {
240  if ($a_entity == "blog") {
241  include_once("./Modules/Blog/classes/class.ilObjBlog.php");
242  $dir = ilObjBlog::initStorage($a_set["Id"]);
243  $a_set["Dir"] = $dir;
244 
245  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
246  $a_set["Style"] = ilObjStyleSheet::lookupObjectStyle($a_set["Id"]);
247 
248  // #14734
249  include_once("./Services/Notes/classes/class.ilNote.php");
250  $a_set["Notes"] = ilNote::commentsActivated($a_set["Id"], 0, "blog");
251  }
252 
253  return $a_set;
254  }
static lookupObjectStyle($a_obj_id)
Lookup object style.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
+ 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 262 of file class.ilBlogDataSet.php.

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

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

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

144  {
145  $ilDB = $this->db;
146 
147  if (!is_array($a_ids)) {
148  $a_ids = array($a_ids);
149  }
150 
151  if ($a_entity == "blog") {
152  switch ($a_version) {
153  case "4.3.0":
154  $this->getDirectDataFromQuery("SELECT bl.id,od.title,od.description," .
155  "bl.notes,bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval" .
156  " FROM il_blog bl" .
157  " JOIN object_data od ON (od.obj_id = bl.id)" .
158  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
159  " AND od.type = " . $ilDB->quote("blog", "text"));
160  break;
161 
162  case "5.0.0":
163  $this->getDirectDataFromQuery("SELECT bl.id,od.title,od.description," .
164  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
165  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
166  "bl.nav_mode,bl.nav_list_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
167  "bl.ov_post" .
168  " FROM il_blog bl" .
169  " JOIN object_data od ON (od.obj_id = bl.id)" .
170  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
171  " AND od.type = " . $ilDB->quote("blog", "text"));
172  break;
173 
174  case "5.3.0":
175  $this->getDirectDataFromQuery("SELECT bl.id,od.title,od.description," .
176  "bl.bg_color,bl.font_color,bl.img,bl.ppic,bl.rss_active,bl.approval," .
177  "bl.abs_shorten,bl.abs_shorten_len,bl.abs_image,bl.abs_img_width,bl.abs_img_height," .
178  "bl.nav_mode,bl.nav_list_mon_with_post,bl.nav_list_mon,bl.keywords,bl.authors,bl.nav_order," .
179  "bl.ov_post" .
180  " FROM il_blog bl" .
181  " JOIN object_data od ON (od.obj_id = bl.id)" .
182  " WHERE " . $ilDB->in("bl.id", $a_ids, false, "integer") .
183  " AND od.type = " . $ilDB->quote("blog", "text"));
184  break;
185  }
186  }
187 
188  if ($a_entity == "blog_posting") {
189  switch ($a_version) {
190  case "4.3.0":
191  case "5.0.0":
192  case "5.3.0":
193  $this->getDirectDataFromQuery("SELECT id,blog_id,title,created,author,approved" .
194  " FROM il_blog_posting WHERE " .
195  $ilDB->in("blog_id", $a_ids, false, "integer"));
196  foreach ($this->data as $idx => $item) {
197  // create full export id
198  $this->data[$idx]["Author"] = $this->createObjectExportId("usr", $item["Author"]);
199  }
200  break;
201  }
202 
203  // keywords
204  include_once("./Modules/Blog/classes/class.ilBlogPosting.php");
205  include_once("./Services/MetaData/classes/class.ilMDKeyword.php");
206  foreach ($this->data as $idx => $item) {
207  $blog_id = ilBlogPosting::lookupBlogId($item["Id"]);
208  $keywords = ilBlogPosting::getKeywords($blog_id, $item["Id"]);
209  if ($keywords) {
210  foreach ($keywords as $kidx => $keyword) {
211  $this->data[$idx]["Keyword" . $kidx] = $keyword;
212  }
213  }
214  }
215  }
216  }
Add some data
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)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $current_blog

ilBlogDataSet::$current_blog
protected

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

◆ $style_map

ilBlogDataSet::$style_map = array()
static

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

Referenced by ilBlogImporter\finalProcessing().


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