ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilPCBlog.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 class ilPCBlog extends ilPageContent
28 {
29  protected ilObjUser $user;
30 
31  public function init(): void
32  {
33  global $DIC;
34 
35  $this->user = $DIC->user();
36  $this->setType("blog");
37  }
38 
39  public function create(
40  ilPageObject $a_pg_obj,
41  string $a_hier_id,
42  string $a_pc_id = ""
43  ): void {
44  $this->createInitialChildNode($a_hier_id, $a_pc_id, "Blog");
45  }
46 
50  public function setData(
51  int $a_blog_id,
52  ?array $a_posting_ids = null
53  ): void {
54  $ilUser = $this->user;
55 
56  $this->getChildNode()->setAttribute("Id", (string) $a_blog_id);
57  $this->getChildNode()->setAttribute("User", (string) $ilUser->getId());
58 
59  // remove all children first
60  $children = $this->getChildNode()->childNodes;
61  if ($children) {
62  $this->dom_util->deleteAllChilds($this->getChildNode());
63  }
64 
65  if (count($a_posting_ids)) {
66  foreach ($a_posting_ids as $posting_id) {
67  $post_node = $this->dom_doc->createElement("BlogPosting");
68  $post_node = $this->getChildNode()->appendChild($post_node);
69  $post_node->setAttribute("Id", (string) $posting_id);
70  }
71  }
72  }
73 
74  public function getBlogId(): int
75  {
76  if (is_object($this->getChildNode())) {
77  return (int) $this->getChildNode()->getAttribute("Id");
78  }
79  return 0;
80  }
81 
85  public function getPostings(): array
86  {
87  $res = array();
88  if (is_object($this->getChildNode())) {
89  $children = $this->getChildNode()->childNodes;
90  if ($children) {
91  foreach ($children as $child) {
92  $res[] = (int) $child->getAttribute("Id");
93  }
94  }
95  }
96  return $res;
97  }
98 }
setType(string $a_type)
Set Type.
$res
Definition: ltiservices.php:66
ilObjUser $user
Content object of ilPageObject (see ILIAS DTD).
Class ilPCBlog Blog content object (see ILIAS DTD)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
global $DIC
Definition: shib_login.php:26
getPostings()
Get blog postings.
setData(int $a_blog_id, ?array $a_posting_ids=null)
Set blog settings.
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])