ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilPCBlog.php
Go to the documentation of this file.
1<?php
2
26{
28 protected ilObjUser $user;
29
30 public function init(): void
31 {
32 global $DIC;
33
34 $this->user = $DIC->user();
35 $this->setType("blog");
36 }
37
38 public function setNode(php4DOMElement $a_node): void
39 {
40 parent::setNode($a_node); // this is the PageContent node
41 $this->blog_node = $a_node->first_child(); // this is the blog node
42 }
43
44 public function create(
45 ilPageObject $a_pg_obj,
46 string $a_hier_id,
47 string $a_pc_id = ""
48 ): void {
49 $this->node = $this->createPageContentNode();
50 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
51 $this->blog_node = $this->dom->create_element("Blog");
52 $this->blog_node = $this->node->append_child($this->blog_node);
53 }
54
58 public function setData(
59 int $a_blog_id,
60 array $a_posting_ids = null
61 ): void {
62 $ilUser = $this->user;
63
64 $this->blog_node->set_attribute("Id", $a_blog_id);
65 $this->blog_node->set_attribute("User", $ilUser->getId());
66
67 // remove all children first
68 $children = $this->blog_node->child_nodes();
69 if ($children) {
70 foreach ($children as $child) {
71 $this->blog_node->remove_child($child);
72 }
73 }
74
75 if (count($a_posting_ids)) {
76 foreach ($a_posting_ids as $posting_id) {
77 $post_node = $this->dom->create_element("BlogPosting");
78 $post_node = $this->blog_node->append_child($post_node);
79 $post_node->set_attribute("Id", $posting_id);
80 }
81 }
82 }
83
84 public function getBlogId(): int
85 {
86 if (is_object($this->blog_node)) {
87 return (int) $this->blog_node->get_attribute("Id");
88 }
89 return 0;
90 }
91
95 public function getPostings(): array
96 {
97 $res = array();
98 if (is_object($this->blog_node)) {
99 $children = $this->blog_node->child_nodes();
100 if ($children) {
101 foreach ($children as $child) {
102 $res[] = (int) $child->get_attribute("Id");
103 }
104 }
105 }
106 return $res;
107 }
108}
const IL_INSERT_AFTER
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
php4DOMElement $blog_node
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
setData(int $a_blog_id, array $a_posting_ids=null)
Set blog settings.
getPostings()
Get blog postings.
init()
Init object.
setNode(php4DOMElement $a_node)
Set xml node of page content.
ilObjUser $user
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$res
Definition: ltiservices.php:69