ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCBlog.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
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}
User class.
Class ilPCBlog Blog content object (see ILIAS DTD)
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
getPostings()
Get blog postings.
init()
Init object.
setData(int $a_blog_id, ?array $a_posting_ids=null)
Set blog settings.
ilObjUser $user
Content object of ilPageObject (see ILIAS DTD).
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26