ILIAS  release_8 Revision v8.24
class.ilLPXmlWriter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
5
12{
13 private bool $add_header = true;
14 private string $timestamp = "";
15 private bool $include_ref_ids = false;
16 private array $type_filter = array();
17
18 protected ilDBInterface $db;
19
23 public function __construct(bool $a_add_header)
24 {
25 global $DIC;
26
27 $this->db = $DIC->database();
28 $this->add_header = $a_add_header;
30 }
31
36 public function setTimestamp(string $a_val): void
37 {
38 $this->timestamp = $a_val;
39 }
40
45 public function getTimestamp(): string
46 {
47 return $this->timestamp;
48 }
49
50 public function setIncludeRefIds(bool $a_val): void
51 {
52 $this->include_ref_ids = $a_val;
53 }
54
55 public function getIncludeRefIds(): bool
56 {
58 }
59
64 public function setTypeFilter(array $a_val): void
65 {
66 $this->type_filter = $a_val;
67 }
68
73 public function getTypeFilter(): array
74 {
75 return $this->type_filter;
76 }
77
83 public function write(): void
84 {
85 $this->init();
86 if ($this->add_header) {
87 $this->buildHeader();
88 }
89 $this->addLPInformation();
90 }
91
92 protected function buildHeader(): void
93 {
94 $this->xmlHeader();
95 }
96
97 protected function init(): void
98 {
99 $this->xmlClear();
100 }
101
102 public function addLPInformation(): void
103 {
104 $this->xmlStartTag('LPData', array());
105 $set = $this->db->query(
106 $q = "SELECT * FROM ut_lp_marks " .
107 " WHERE status_changed >= " . $this->db->quote(
108 $this->getTimestamp(),
109 "timestamp"
110 )
111 );
112
113 while ($rec = $this->db->fetchAssoc($set)) {
114 $ref_ids = array();
115 if ($this->getIncludeRefIds()) {
116 $ref_ids = ilObject::_getAllReferences((int) $rec["obj_id"]);
117 }
118
119 if (!is_array($this->getTypeFilter()) ||
120 (count($this->getTypeFilter()) == 0) ||
121 in_array(
122 ilObject::_lookupType((int) $rec["obj_id"]),
123 $this->getTypeFilter()
124 )) {
125 $this->xmlElement(
126 'LPChange',
127 array(
128 'UserId' => (int) $rec["usr_id"],
129 'ObjId' => (int) $rec["obj_id"],
130 'RefIds' => implode(",", $ref_ids),
131 'Timestamp' => $rec["status_changed"],
132 'LPStatus' => (int) $rec["status"]
133 )
134 );
135 }
136 }
137 $this->xmlEndTag('LPData');
138 }
139}
XML writer learning progress.
setIncludeRefIds(bool $a_val)
getTimestamp()
Get timestamp.
getTypeFilter()
Get type filter.
ilDBInterface $db
__construct(bool $a_add_header)
Constructor.
setTimestamp(string $a_val)
Set timestamp.
setTypeFilter(array $a_val)
Set type filter.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlClear()
clears xmlStr
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc