ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjectXMLWriter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjectXMLWriter:
+ Collaboration diagram for ilObjectXMLWriter:

Public Member Functions

 __construct ()
 
 setMode (int $a_mode)
 
 getMode ()
 
 setHighlighter (ilLuceneHighlighterResultParser $a_highlighter)
 
 getHighlighter ()
 
 enablePermissionCheck (bool $a_status)
 
 isPermissionCheckEnabled ()
 
 setUserId (int $a_id)
 
 getUserId ()
 
 enableOperations (bool $a_status)
 
 enabledOperations ()
 
 enableReferences (bool $a_stat)
 
 enabledReferences ()
 
 setObjects (array $objects)
 
 getObjects ()
 
 start ()
 
 getXML ()
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Static Public Member Functions

static appendPathToObject (ilXmlWriter $writer, int $refid)
 

Data Fields

const MODE_SEARCH_RESULT = 1
 
const TIMING_DEACTIVATED = 0
 
const TIMING_TEMPORARILY_AVAILABLE = 1
 
const TIMING_PRESETTING = 2
 
const TIMING_VISIBILITY_OFF = 0
 
const TIMING_VISIBILITY_ON = 1
 

Protected Attributes

string $xml
 
bool $enable_operations = false
 
bool $enable_references = true
 
array $objects = array()
 
int $user_id = 0
 
bool $check_permission = false
 

Private Member Functions

 appendTimeTargets (int $a_ref_id)
 Append time target settings for items inside of courses. More...
 
 appendObjectProperties (ilObject $obj)
 
 appendOperations (int $a_ref_id, string $a_type)
 
 appendPath (int $refid)
 
 buildHeader ()
 
 buildFooter ()
 
 getAccessInfo (ilObject $object, int $ref_id)
 

Private Attributes

int $mode = 0
 
ilLuceneHighlighterResultParser $highlighter = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning XML writer class Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 28 of file class.ilObjectXMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectXMLWriter::__construct ( )

Definition at line 49 of file class.ilObjectXMLWriter.php.

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

50  {
51  global $DIC;
52 
53  $ilUser = $DIC['ilUser'];
54 
56  $this->user_id = $ilUser->getId();
57  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ appendObjectProperties()

ilObjectXMLWriter::appendObjectProperties ( ilObject  $obj)
private

Definition at line 270 of file class.ilObjectXMLWriter.php.

References ilObject\getType(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

270  : void
271  {
272  switch ($obj->getType()) {
273  case 'file':
274  if (!$obj instanceof ilObjFile) {
275  break;
276  }
277  $size = $obj->getFileSize();
278  $extension = $obj->getFileExtension();
279  $this->xmlStartTag('Properties');
280  $this->xmlElement("Property", array('name' => 'fileSize'), (string) $size);
281  $this->xmlElement("Property", array('name' => 'fileExtension'), (string) $extension);
282  $this->xmlElement(
283  'Property',
284  array('name' => 'fileVersion'),
285  (string) $obj->getVersion()
286  );
287  $this->xmlEndTag('Properties');
288  break;
289  }
290  }
xmlEndTag(string $tag)
Writes an endtag.
Class ilObjFile.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendOperations()

ilObjectXMLWriter::appendOperations ( int  $a_ref_id,
string  $a_type 
)
private

Definition at line 292 of file class.ilObjectXMLWriter.php.

References $DIC, enabledOperations(), ilRbacReview\lookupCreateOperationIds(), null, and ilXmlWriter\xmlElement().

Referenced by getXML().

292  : void
293  {
294  global $DIC;
295 
296  $ilAccess = $DIC['ilAccess'];
297  $rbacreview = $DIC['rbacreview'];
298  $objDefinition = $DIC['objDefinition'];
299 
300  if ($this->enabledOperations()) {
301  $ops = $rbacreview->getOperationsOnTypeString($a_type);
302  if (is_array($ops)) {
303  foreach ($ops as $ops_id) {
304  $operation = $rbacreview->getOperation($ops_id);
305 
306  if (count($operation) && $ilAccess->checkAccessOfUser(
307  $this->getUserId(),
308  $operation['operation'],
309  'view',
310  $a_ref_id
311  )) {
312  $this->xmlElement('Operation', null, $operation['operation']);
313  }
314  }
315  }
316 
317  $objects = $objDefinition->getCreatableSubObjects($a_type);
318  $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
319  $creation_operations = array();
320  foreach ($objects as $type => $info) {
321  $ops_id = $ops_ids[$type] ?? null;
322 
323  if (!$ops_id) {
324  continue;
325  }
326 
327  $operation = $rbacreview->getOperation($ops_id);
328 
329  if (count($operation) && $ilAccess->checkAccessOfUser(
330  $this->getUserId(),
331  $operation['operation'],
332  'view',
333  $a_ref_id
334  )) {
335  $this->xmlElement('Operation', null, $operation['operation']);
336  }
337  }
338  }
339  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static lookupCreateOperationIds(array $a_type_arr)
Lookup operation ids.
global $DIC
Definition: shib_login.php:22
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendPath()

ilObjectXMLWriter::appendPath ( int  $refid)
private

Definition at line 341 of file class.ilObjectXMLWriter.php.

Referenced by getXML().

341  : void
342  {
343  self::appendPathToObject($this, $refid);
344  }
+ Here is the caller graph for this function:

◆ appendPathToObject()

static ilObjectXMLWriter::appendPathToObject ( ilXmlWriter  $writer,
int  $refid 
)
static

Definition at line 374 of file class.ilObjectXMLWriter.php.

References $DIC, $lng, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by ilSoapRoleObjectXMLWriter\start().

374  : void
375  {
376  global $DIC;
377 
378  $tree = $DIC['tree'];
379  $lng = $DIC['lng'];
380  $items = $tree->getPathFull($refid);
381  $writer->xmlStartTag("Path");
382  foreach ($items as $item) {
383  if ((int) $item["ref_id"] === $refid) {
384  continue;
385  }
386  if ($item["type"] === "root") {
387  $item["title"] = $lng->txt("repository");
388  }
389  $writer->xmlElement("Element", array("ref_id" => $item["ref_id"], "type" => $item["type"]), $item["title"]);
390  }
391  $writer->xmlEndTag("Path");
392  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendTimeTargets()

ilObjectXMLWriter::appendTimeTargets ( int  $a_ref_id)
private

Append time target settings for items inside of courses.

Parameters
int$ref_idReference id of object
Returns
void

Definition at line 224 of file class.ilObjectXMLWriter.php.

References $DIC, ilObjectActivation\getItem(), ILIAS\Repository\int(), ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, ilObjectActivation\TIMINGS_PRESETTING, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

224  : void
225  {
226  global $DIC;
227 
228  $tree = $DIC['tree'];
229 
230  if (!$tree->checkForParentType($a_ref_id, 'crs')) {
231  return;
232  }
233  $time_targets = ilObjectActivation::getItem($a_ref_id);
234 
235  switch ($time_targets['timing_type']) {
237  $type = self::TIMING_TEMPORARILY_AVAILABLE;
238  break;
240  $type = self::TIMING_PRESETTING;
241  break;
243  default:
244  $type = self::TIMING_DEACTIVATED;
245  break;
246  }
247 
248  $this->xmlStartTag('TimeTarget', array('type' => $type));
249 
250  $vis = (int) $time_targets['visible'] === 0 ? self::TIMING_VISIBILITY_OFF : self::TIMING_VISIBILITY_ON;
251  $this->xmlElement(
252  'Timing',
253  array('starting_time' => $time_targets['timing_start'],
254  'ending_time' => $time_targets['timing_end'],
255  'visibility' => $vis
256  )
257  );
258 
259  $this->xmlElement(
260  'Suggestion',
261  array(
262  'starting_time' => $time_targets['suggestion_start'],
263  'ending_time' => $time_targets['suggestion_end'],
264  'changeable' => $time_targets['changeable']
265  )
266  );
267  $this->xmlEndTag('TimeTarget');
268  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: shib_login.php:22
static getItem(int $ref_id)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFooter()

ilObjectXMLWriter::buildFooter ( )
private

Definition at line 354 of file class.ilObjectXMLWriter.php.

References ilXmlWriter\xmlEndTag().

Referenced by start().

354  : void
355  {
356  $this->xmlEndTag('Objects');
357  }
xmlEndTag(string $tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildHeader()

ilObjectXMLWriter::buildHeader ( )
private

Definition at line 346 of file class.ilObjectXMLWriter.php.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), ilXmlWriter\xmlSetGenCmt(), and ilXmlWriter\xmlStartTag().

Referenced by start().

346  : void
347  {
348  $this->xmlSetDtdDef("<!DOCTYPE Objects PUBLIC \"-//ILIAS//DTD ILIAS Repositoryobjects//EN\" \"" . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_object_4_0.dtd\">");
349  $this->xmlSetGenCmt("Export of ILIAS objects");
350  $this->xmlHeader();
351  $this->xmlStartTag("Objects");
352  }
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
xmlHeader()
Writes xml header.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enabledOperations()

ilObjectXMLWriter::enabledOperations ( )

Definition at line 104 of file class.ilObjectXMLWriter.php.

References $enable_operations.

Referenced by appendOperations().

104  : bool
105  {
107  }
+ Here is the caller graph for this function:

◆ enabledReferences()

ilObjectXMLWriter::enabledReferences ( )

Definition at line 114 of file class.ilObjectXMLWriter.php.

References $enable_references.

Referenced by getXML().

114  : bool
115  {
117  }
+ Here is the caller graph for this function:

◆ enableOperations()

ilObjectXMLWriter::enableOperations ( bool  $a_status)

Definition at line 99 of file class.ilObjectXMLWriter.php.

99  : void
100  {
101  $this->enable_operations = $a_status;
102  }

◆ enablePermissionCheck()

ilObjectXMLWriter::enablePermissionCheck ( bool  $a_status)

Definition at line 79 of file class.ilObjectXMLWriter.php.

79  : void
80  {
81  $this->check_permission = $a_status;
82  }

◆ enableReferences()

ilObjectXMLWriter::enableReferences ( bool  $a_stat)

Definition at line 109 of file class.ilObjectXMLWriter.php.

109  : void
110  {
111  $this->enable_references = $a_stat;
112  }

◆ getAccessInfo()

ilObjectXMLWriter::getAccessInfo ( ilObject  $object,
int  $ref_id 
)
private

Definition at line 359 of file class.ilObjectXMLWriter.php.

References $DIC, ilObject\getId(), ilObject\getType(), and getUserId().

Referenced by getXML().

359  : string
360  {
361  global $DIC;
362 
363  $ilAccess = $DIC['ilAccess'];
364 
365  $ilAccess->checkAccessOfUser($this->getUserId(), 'read', 'view', $ref_id, $object->getType(), $object->getId());
366 
367  if (!$info = $ilAccess->getInfo()) {
368  return 'granted';
369  }
370 
371  return $info[0]['type'];
372  }
$ref_id
Definition: ltiauth.php:65
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHighlighter()

ilObjectXMLWriter::getHighlighter ( )

Definition at line 74 of file class.ilObjectXMLWriter.php.

References $highlighter.

75  {
76  return $this->highlighter;
77  }
Parses result XML from lucene search highlight.
ilLuceneHighlighterResultParser $highlighter

◆ getMode()

ilObjectXMLWriter::getMode ( )

Definition at line 64 of file class.ilObjectXMLWriter.php.

References $mode.

64  : int
65  {
66  return $this->mode;
67  }

◆ getObjects()

ilObjectXMLWriter::getObjects ( )

Definition at line 124 of file class.ilObjectXMLWriter.php.

References $objects.

Referenced by start().

124  : array
125  {
126  return $this->objects;
127  }
+ Here is the caller graph for this function:

◆ getUserId()

ilObjectXMLWriter::getUserId ( )

Definition at line 94 of file class.ilObjectXMLWriter.php.

References $user_id.

Referenced by getAccessInfo().

94  : int
95  {
96  return $this->user_id;
97  }
+ Here is the caller graph for this function:

◆ getXML()

◆ isPermissionCheckEnabled()

ilObjectXMLWriter::isPermissionCheckEnabled ( )

Definition at line 84 of file class.ilObjectXMLWriter.php.

References $check_permission.

Referenced by start().

84  : bool
85  {
87  }
+ Here is the caller graph for this function:

◆ setHighlighter()

ilObjectXMLWriter::setHighlighter ( ilLuceneHighlighterResultParser  $a_highlighter)

Definition at line 69 of file class.ilObjectXMLWriter.php.

69  : void
70  {
71  $this->highlighter = $a_highlighter;
72  }

◆ setMode()

ilObjectXMLWriter::setMode ( int  $a_mode)

Definition at line 59 of file class.ilObjectXMLWriter.php.

59  : void
60  {
61  $this->mode = $a_mode;
62  }

◆ setObjects()

ilObjectXMLWriter::setObjects ( array  $objects)

Definition at line 119 of file class.ilObjectXMLWriter.php.

References $objects.

119  : void
120  {
121  $this->objects = $objects;
122  }

◆ setUserId()

ilObjectXMLWriter::setUserId ( int  $a_id)

Definition at line 89 of file class.ilObjectXMLWriter.php.

89  : void
90  {
91  $this->user_id = $a_id;
92  }

◆ start()

ilObjectXMLWriter::start ( )

Definition at line 129 of file class.ilObjectXMLWriter.php.

References $DIC, buildFooter(), buildHeader(), getObjects(), and isPermissionCheckEnabled().

129  : bool
130  {
131  global $DIC;
132 
133  $ilAccess = $DIC['ilAccess'];
134  $objDefinition = $DIC['objDefinition'];
135 
136  $this->buildHeader();
137  foreach ($this->getObjects() as $object) {
138  if (method_exists($object, 'getType') &&
139  $this->isPermissionCheckEnabled() &&
140  $objDefinition->isRBACObject($object->getType()) &&
141  !$ilAccess->checkAccessOfUser(
142  $this->getUserId(),
143  'read',
144  '',
145  $object->getRefId()
146  )) {
147  continue;
148  }
149  $this->appendObject($object);
150  }
151  $this->buildFooter();
152  return true;
153  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Field Documentation

◆ $check_permission

bool ilObjectXMLWriter::$check_permission = false
protected

Definition at line 47 of file class.ilObjectXMLWriter.php.

Referenced by isPermissionCheckEnabled().

◆ $enable_operations

bool ilObjectXMLWriter::$enable_operations = false
protected

Definition at line 43 of file class.ilObjectXMLWriter.php.

Referenced by enabledOperations().

◆ $enable_references

bool ilObjectXMLWriter::$enable_references = true
protected

Definition at line 44 of file class.ilObjectXMLWriter.php.

Referenced by enabledReferences().

◆ $highlighter

ilLuceneHighlighterResultParser ilObjectXMLWriter::$highlighter = null
private

Definition at line 40 of file class.ilObjectXMLWriter.php.

Referenced by getHighlighter().

◆ $mode

int ilObjectXMLWriter::$mode = 0
private

Definition at line 39 of file class.ilObjectXMLWriter.php.

Referenced by getMode().

◆ $objects

array ilObjectXMLWriter::$objects = array()
protected

Definition at line 45 of file class.ilObjectXMLWriter.php.

Referenced by getObjects(), and setObjects().

◆ $user_id

int ilObjectXMLWriter::$user_id = 0
protected

Definition at line 46 of file class.ilObjectXMLWriter.php.

Referenced by getUserId().

◆ $xml

string ilObjectXMLWriter::$xml
protected

Definition at line 42 of file class.ilObjectXMLWriter.php.

◆ MODE_SEARCH_RESULT

const ilObjectXMLWriter::MODE_SEARCH_RESULT = 1

◆ TIMING_DEACTIVATED

const ilObjectXMLWriter::TIMING_DEACTIVATED = 0

◆ TIMING_PRESETTING

const ilObjectXMLWriter::TIMING_PRESETTING = 2

◆ TIMING_TEMPORARILY_AVAILABLE

const ilObjectXMLWriter::TIMING_TEMPORARILY_AVAILABLE = 1

◆ TIMING_VISIBILITY_OFF

const ilObjectXMLWriter::TIMING_VISIBILITY_OFF = 0

Definition at line 36 of file class.ilObjectXMLWriter.php.

◆ TIMING_VISIBILITY_ON

const ilObjectXMLWriter::TIMING_VISIBILITY_ON = 1

Definition at line 37 of file class.ilObjectXMLWriter.php.


The documentation for this class was generated from the following file: