ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  function setTimestamp($a_val)
37  {
38  $this->timestamp = $a_val;
39  }
40 
46  function getTimestamp()
47  {
48  return $this->timestamp;
49  }
50 
56  function setIncludeRefIds($a_val)
57  {
58  $this->include_ref_ids = $a_val;
59  }
60 
66  function getIncludeRefIds()
67  {
69  }
70 
76  function setTypeFilter($a_val)
77  {
78  $this->type_filter = $a_val;
79  }
80 
86  function getTypeFilter()
87  {
88  return $this->type_filter;
89  }
90 
96  public function write()
97  {
98  $this->init();
99  if($this->add_header)
100  {
101  $this->buildHeader();
102  }
103  $this->addLPInformation();
104  }
105 
110  protected function buildHeader()
111  {
112  //$this->xmlSetDtdDef("<!DOCTYPE LearningProgress PUBLIC \"-//ILIAS//DTD WebLinkAdministration//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_weblinks_4_0.dtd\">");
113  //$this->xmlSetGenCmt("WebLink Object");
114  $this->xmlHeader();
115 
116  return true;
117  }
118 
119 
125  protected function init()
126  {
127  $this->xmlClear();
128 
129 /* if(!$this->obj_id)
130  {
131  throw new UnexpectedValueException('No obj_id given: ');
132  }*/
133  }
134 
141  function addLPInformation()
142  {
143  global $ilDB;
144 
145  $this->xmlStartTag('LPData', array());
146 
147  $set = $ilDB->query($q = "SELECT * FROM ut_lp_marks ".
148  " WHERE status_changed >= ".$ilDB->quote($this->getTimestamp(), "timestamp")
149  );
150 
151  while ($rec = $ilDB->fetchAssoc($set))
152  {
153  $ref_ids = array();
154  if ($this->getIncludeRefIds())
155  {
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  {
163  $this->xmlElement('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 
178 }
179 ?>
buildHeader()
Build XML header.
__construct($a_add_header)
Constructor.
init()
Init xml writer.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
write()
Write XML.
XML writer class.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
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.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
xmlClear()
clears xmlStr public