ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 include_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 $DIC;
143 
144  $ilDB = $DIC['ilDB'];
145 
146  $this->xmlStartTag('LPData', array());
147 
148  $set = $ilDB->query(
149  $q = "SELECT * FROM ut_lp_marks " .
150  " WHERE status_changed >= " . $ilDB->quote($this->getTimestamp(), "timestamp")
151  );
152 
153  while ($rec = $ilDB->fetchAssoc($set)) {
154  $ref_ids = array();
155  if ($this->getIncludeRefIds()) {
156  $ref_ids = ilObject::_getAllReferences($rec["obj_id"]);
157  }
158 
159  if (!is_array($this->getTypeFilter()) ||
160  (count($this->getTypeFilter()) == 0) ||
161  in_array(ilObject::_lookupType($rec["obj_id"]), $this->getTypeFilter())) {
162  $this->xmlElement(
163  'LPChange',
164  array(
165  'UserId' => $rec["usr_id"],
166  'ObjId' => $rec["obj_id"],
167  'RefIds' => implode(",", $ref_ids),
168  'Timestamp' => $rec["status_changed"],
169  'LPStatus' => $rec["status"]
170  )
171  );
172  }
173  }
174 
175  $this->xmlEndTag('LPData');
176  }
177 }
buildHeader()
Build XML header.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
__construct($a_add_header)
Constructor.
global $DIC
Definition: saml.php:7
init()
Init xml writer.
write()
Write XML.
XML writer class.
getTimestamp()
Get timestamp.
getIncludeRefIds()
Get include ref ids.
static _getAllReferences($a_id)
get all reference ids of object
xmlEndTag($tag)
Writes an endtag.
setTypeFilter($a_val)
Set type filter.
addLPInformation()
Add lp information as xml.
setIncludeRefIds($a_val)
Set include ref ids.
setTimestamp($a_val)
Set timestamp.
XML writer learning progress.
getTypeFilter()
Get type filter.
xmlHeader()
Writes xml header public.
static _lookupType($a_id, $a_reference=false)
lookup object type
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
xmlClear()
clears xmlStr public