ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCVerification.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
27 {
29  protected ilObjUser $user;
30 
31  public function init(): void
32  {
33  global $DIC;
34 
35  $this->user = $DIC->user();
36  $this->setType('vrfc');
37  }
38 
39  public function setNode(php4DOMElement $a_node): void
40  {
41  parent::setNode($a_node); // this is the PageContent node
42  $this->vrfc_node = $a_node->first_child(); // this is the verification node
43  }
44 
45  public function create(
46  ilPageObject $a_pg_obj,
47  string $a_hier_id,
48  string $a_pc_id = ""
49  ): void {
50  $this->node = $this->createPageContentNode();
51  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
52  $this->vrfc_node = $this->dom->create_element('Verification');
53  $this->vrfc_node = $this->node->append_child($this->vrfc_node);
54  }
55 
56  public function setData(
57  string $a_type,
58  int $a_id
59  ): void {
60  $this->vrfc_node->set_attribute('Type', $a_type);
61  $this->vrfc_node->set_attribute('Id', $a_id);
62  $this->vrfc_node->set_attribute('User', $this->user->getId());
63  }
64 
68  public function getData(): ?array
69  {
70  if (is_object($this->vrfc_node)) {
71  return [
72  'id' => $this->vrfc_node->get_attribute('Id'),
73  'type' => $this->vrfc_node->get_attribute('Type'),
74  'user' => $this->vrfc_node->get_attribute('User')
75  ];
76  }
77 
78  return null;
79  }
80 
84  public static function getLangVars(): array
85  {
86  return [
87  'pc_vrfc',
88  'ed_insert_verification'
89  ];
90  }
91 
92  public static function isInPortfolioPage(
93  ilPortfolioPage $a_page,
94  string $a_type,
95  int $a_id
96  ): bool {
97  // try to find verification in portfolio page
98  $a_page->buildDom();
99 
100  $dom = $a_page->getDom();
101  if ($dom instanceof php4DOMDocument) {
102  $dom = $dom->myDOMDocument;
103  }
104 
105  $xpath_temp = new DOMXPath($dom);
106  $nodes = $xpath_temp->query('//PageContent/Verification');
107  foreach ($nodes as $node) {
108  if ($node->getAttribute('Type') === $a_type && (int) $node->getAttribute('Id') === $a_id) {
109  return true;
110  }
111  }
112 
113  return false;
114  }
115 }
php4DOMElement $node
setType(string $a_type)
Set Type.
setNode(php4DOMElement $a_node)
buildDom(bool $a_force=false)
static isInPortfolioPage(ilPortfolioPage $a_page, string $a_type, int $a_id)
setData(string $a_type, int $a_id)
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
php4DOMDocument $dom
global $DIC
Definition: feed.php:28
php4DomElement
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
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_INSERT_AFTER
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...