ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLPXmlWriter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Xml/classes/class.ilXmlWriter.php";
5
15{
16 private $add_header = true;
17
18 private $timestamp = "";
19 private $include_ref_ids = false;
20 private $type_filter = array();
21
25 public function __construct($a_add_header)
26 {
27 $this->add_header = $a_add_header;
28 parent::__construct();
29 }
30
36 public function setTimestamp($a_val)
37 {
38 $this->timestamp = $a_val;
39 }
40
46 public function getTimestamp()
47 {
48 return $this->timestamp;
49 }
50
56 public function setIncludeRefIds($a_val)
57 {
58 $this->include_ref_ids = $a_val;
59 }
60
66 public function getIncludeRefIds()
67 {
69 }
70
76 public function setTypeFilter($a_val)
77 {
78 $this->type_filter = $a_val;
79 }
80
86 public function getTypeFilter()
87 {
88 return $this->type_filter;
89 }
90
96 public function write()
97 {
98 $this->init();
99 if ($this->add_header) {
100 $this->buildHeader();
101 }
102 $this->addLPInformation();
103 }
104
109 protected function buildHeader()
110 {
111 //$this->xmlSetDtdDef("<!DOCTYPE LearningProgress PUBLIC \"-//ILIAS//DTD WebLinkAdministration//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_weblinks_4_0.dtd\">");
112 //$this->xmlSetGenCmt("WebLink Object");
113 $this->xmlHeader();
114
115 return true;
116 }
117
118
124 protected function init()
125 {
126 $this->xmlClear();
127
128 /* if(!$this->obj_id)
129 {
130 throw new UnexpectedValueException('No obj_id given: ');
131 }*/
132 }
133
140 public function addLPInformation()
141 {
142 global $ilDB;
143
144 $this->xmlStartTag('LPData', array());
145
146 $set = $ilDB->query(
147 $q = "SELECT * FROM ut_lp_marks " .
148 " WHERE status_changed >= " . $ilDB->quote($this->getTimestamp(), "timestamp")
149 );
150
151 while ($rec = $ilDB->fetchAssoc($set)) {
152 $ref_ids = array();
153 if ($this->getIncludeRefIds()) {
154 $ref_ids = ilObject::_getAllReferences($rec["obj_id"]);
155 }
156
157 if (!is_array($this->getTypeFilter()) ||
158 (count($this->getTypeFilter()) == 0) ||
159 in_array(ilObject::_lookupType($rec["obj_id"]), $this->getTypeFilter())) {
160 $this->xmlElement(
161 'LPChange',
162 array(
163 'UserId' => $rec["usr_id"],
164 'ObjId' => $rec["obj_id"],
165 'RefIds' => implode($ref_ids, ","),
166 'Timestamp' => $rec["status_changed"],
167 'LPStatus' => $rec["status"]
168 )
169 );
170 }
171 }
172
173 $this->xmlEndTag('LPData');
174 }
175}
An exception for terminatinating execution or to throw for unit testing.
XML writer learning progress.
setTimestamp($a_val)
Set timestamp.
getIncludeRefIds()
Get include ref ids.
init()
Init xml writer.
getTimestamp()
Get timestamp.
setTypeFilter($a_val)
Set type filter.
addLPInformation()
Add lp information as xml.
getTypeFilter()
Get type filter.
buildHeader()
Build XML header.
setIncludeRefIds($a_val)
Set include ref ids.
__construct($a_add_header)
Constructor.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlClear()
clears xmlStr @access public
xmlHeader()
Writes xml header @access public.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
global $ilDB