ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCBlog.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPageContent.php");
25 
36 class ilPCBlog extends ilPageContent
37 {
41  protected $user;
42 
46  public function init()
47  {
48  global $DIC;
49 
50  $this->user = $DIC->user();
51  $this->setType("blog");
52  }
53 
57  public function setNode($a_node)
58  {
59  parent::setNode($a_node); // this is the PageContent node
60  $this->blog_node = $a_node->first_child(); // this is the blog node
61  }
62 
69  public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
70  {
71  $this->node = $this->createPageContentNode();
72  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
73  $this->blog_node = $this->dom->create_element("Blog");
74  $this->blog_node = $this->node->append_child($this->blog_node);
75  }
76 
83  public function setData($a_blog_id, array $a_posting_ids = null)
84  {
86 
87  $this->blog_node->set_attribute("Id", $a_blog_id);
88  $this->blog_node->set_attribute("User", $ilUser->getId());
89 
90  // remove all children first
91  $children = $this->blog_node->child_nodes();
92  if ($children) {
93  foreach ($children as $child) {
94  $this->blog_node->remove_child($child);
95  }
96  }
97 
98  if (sizeof($a_posting_ids)) {
99  foreach ($a_posting_ids as $posting_id) {
100  $post_node = $this->dom->create_element("BlogPosting");
101  $post_node = $this->blog_node->append_child($post_node);
102  $post_node->set_attribute("Id", $posting_id);
103  }
104  }
105  }
106 
112  public function getBlogId()
113  {
114  if (is_object($this->blog_node)) {
115  return $this->blog_node->get_attribute("Id");
116  }
117  }
118 
124  public function getPostings()
125  {
126  $res = array();
127  if (is_object($this->blog_node)) {
128  $children = $this->blog_node->child_nodes();
129  if ($children) {
130  foreach ($children as $child) {
131  $res[] = $child->get_attribute("Id");
132  }
133  }
134  }
135  return $res;
136  }
137 }
getBlogId()
Get blog mode.
global $DIC
Definition: saml.php:7
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create blog node in xml.
setType($a_type)
Set Type.
init()
Init page content component.
user()
Definition: user.php:4
Class ilPageContent.
Class ilPCBlog.
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
const IL_INSERT_AFTER
getPostings()
Get blog postings.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
setData($a_blog_id, array $a_posting_ids=null)
Set blog settings.
setNode($a_node)
Set node.