ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCProfile.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 require_once("./Services/COPage/classes/class.ilPageContent.php");
7 
19 {
23  protected $user;
24 
25  public $dom;
26 
30  public function init()
31  {
32  global $DIC;
33 
34  $this->user = $DIC->user();
35  $this->setType("prof");
36  }
37 
41  public function setNode($a_node)
42  {
43  parent::setNode($a_node); // this is the PageContent node
44  $this->prof_node = $a_node->first_child(); // this is the profile node
45  }
46 
53  public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
54  {
55  $this->node = $this->createPageContentNode();
56  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
57  $this->prof_node = $this->dom->create_element("Profile");
58  $this->prof_node = $this->node->append_child($this->prof_node);
59  }
60 
67  public function setFields($a_mode, array $a_fields = null)
68  {
70 
71  $this->prof_node->set_attribute("Mode", $a_mode);
72  $this->prof_node->set_attribute("User", $ilUser->getId());
73 
74  // remove all children first
75  $children = $this->prof_node->child_nodes();
76  if ($children) {
77  foreach ($children as $child) {
78  $this->prof_node->remove_child($child);
79  }
80  }
81 
82  if ($a_mode == "manual") {
83  foreach ($a_fields as $field) {
84  $field_node = $this->dom->create_element("ProfileField");
85  $field_node = $this->prof_node->append_child($field_node);
86  $field_node->set_attribute("Name", $field);
87  }
88  }
89  }
90 
96  public function getMode()
97  {
98  if (is_object($this->prof_node)) {
99  return $this->prof_node->get_attribute("Mode");
100  }
101  }
102 
108  public function getFields()
109  {
110  $res = array();
111  if (is_object($this->prof_node)) {
112  $children = $this->prof_node->child_nodes();
113  if ($children) {
114  foreach ($children as $child) {
115  $res[] = $child->get_attribute("Name");
116  }
117  }
118  }
119  return $res;
120  }
121 
126  public static function getLangVars()
127  {
128  return array("pc_prof", "ed_insert_profile");
129  }
130 }
init()
Init page content component.
global $DIC
Definition: saml.php:7
static getLangVars()
Get lang vars needed for editing.
setNode($a_node)
Set node.
setType($a_type)
Set Type.
user()
Definition: user.php:4
Class ilPageContent.
setFields($a_mode, array $a_fields=null)
Set profile settings.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create profile node in xml.
foreach($_POST as $key=> $value) $res
Class ilPCProfile.
$ilUser
Definition: imgupload.php:18
const IL_INSERT_AFTER
getFields()
Get profile settings.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
getMode()
Get profile mode.