ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjectXMLWriter Class Reference

XML writer class. More...

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

Public Member Functions

 __construct ()
 constructor More...
 
 setMode ($a_mode)
 
 setHighlighter ($a_highlighter)
 
 enablePermissionCheck ($a_status)
 
 isPermissionCheckEnabled ()
 
 setUserId ($a_id)
 
 getUserId ()
 
 enableOperations ($a_status)
 
 enabledOperations ()
 
 enableReferences ($a_stat)
 
 enabledReferences ()
 
 setObjects ($objects)
 
 __getObjects ()
 
 start ()
 
 getXML ()
 
 __appendTimeTargets ($a_ref_id)
 Append time target settings for items inside of courses. More...
 
 __appendObjectProperties (ilObject $obj)
 Append object properties. More...
 
 __appendOperations ($a_ref_id, $a_type)
 
 __appendPath ($refid)
 
 __buildHeader ()
 
 __buildFooter ()
 
 __getAccessInfo (&$object, $ref_id)
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header @access public. More...
 
 xmlStartTag ($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=true, $escape=true)
 Writes data. More...
 
 xmlElement ($tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=true)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr @access public More...
 

Static Public Member Functions

static appendPathToObject ($writer, $refid)
 
- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 

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
 
 $ilias
 
 $xml
 
 $enable_operations = false
 
 $objects = array()
 
 $user_id = 0
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Protected Attributes

 $check_permission = false
 

Private Attributes

 $mode = 0
 
 $highlighter = null
 
 $enable_references = true
 

Detailed Description

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilObjectXMLWriter::__construct ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding @access public

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

57 {
58 global $DIC;
59
60 $ilias = $DIC['ilias'];
61 $ilUser = $DIC['ilUser'];
62
63 parent::__construct();
64
65 $this->ilias =&$ilias;
66 $this->user_id = $ilUser->getId();
67 }
redirection script todo: (a better solution should control the processing via a xml file)
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18

References $DIC, $ilias, and $ilUser.

Member Function Documentation

◆ __appendObjectProperties()

ilObjectXMLWriter::__appendObjectProperties ( ilObject  $obj)

Append object properties.

Parameters
ilObject$obj

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

318 {
319 switch ($obj->getType()) {
320
321 case 'file':
322 include_once './Modules/File/classes/class.ilObjFileAccess.php';
324 $extension = ilObjFileAccess::_lookupSuffix($obj->getId());
325 $this->xmlStartTag('Properties');
326 $this->xmlElement("Property", array('name' => 'fileSize'), (int) $size);
327 $this->xmlElement("Property", array('name' => 'fileExtension'), (string) $extension);
328 // begin-patch fm
329 $this->xmlElement('Property', array('name' => 'fileVersion'), (string) ilObjFileAccess::_lookupVersion($obj->getId()));
330 // end-patch fm
331 $this->xmlEndTag('Properties');
332 break;
333 }
334 }
$size
Definition: RandomTest.php:84
static _lookupFileSize($a_id)
Quickly looks up the file size from the database and returns the number of bytes.
static _lookupVersion($a_id)
lookup version
static _lookupSuffix($a_id)
lookup suffix
getType()
get object type @access public
getId()
get object id @access public
xmlEndTag($tag)
Writes an endtag.
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.

References $size, ilObjFileAccess\_lookupFileSize(), ilObjFileAccess\_lookupSuffix(), ilObjFileAccess\_lookupVersion(), ilObject\getId(), ilObject\getType(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ __appendOperations()

ilObjectXMLWriter::__appendOperations (   $a_ref_id,
  $a_type 
)

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

338 {
339 global $DIC;
340
341 $ilAccess = $DIC['ilAccess'];
342 $rbacreview = $DIC['rbacreview'];
343 $objDefinition = $DIC['objDefinition'];
344
345 if ($this->enabledOperations()) {
346 $ops = $rbacreview->getOperationsOnTypeString($a_type);
347 if (is_array($ops)) {
348 foreach ($ops as $ops_id) {
349 $operation = $rbacreview->getOperation($ops_id);
350
351 if (count($operation) && $ilAccess->checkAccessOfUser($this->getUserId(), $operation['operation'], 'view', $a_ref_id)) {
352 $this->xmlElement('Operation', null, $operation['operation']);
353 }
354 }
355 }
356
357 // Create operations
358 // Get creatable objects
359 $objects = $objDefinition->getCreatableSubObjects($a_type);
360 $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
361 $creation_operations = array();
362 foreach ($objects as $type => $info) {
363 $ops_id = $ops_ids[$type];
364
365 if (!$ops_id) {
366 continue;
367 }
368
369 $operation = $rbacreview->getOperation($ops_id);
370
371 if (count($operation) && $ilAccess->checkAccessOfUser($this->getUserId(), $operation['operation'], 'view', $a_ref_id)) {
372 $this->xmlElement('Operation', null, $operation['operation']);
373 }
374 }
375 }
376 return true;
377 }
static lookupCreateOperationIds($a_type_arr)
Lookup operation ids.
$info
Definition: index.php:5
$type
$a_type
Definition: workflow.php:92

References $a_type, $DIC, $info, $objects, $type, enabledOperations(), ilRbacReview\lookupCreateOperationIds(), and ilXmlWriter\xmlElement().

+ Here is the call graph for this function:

◆ __appendPath()

ilObjectXMLWriter::__appendPath (   $refid)

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

381 {
383 }
static appendPathToObject($writer, $refid)

References appendPathToObject().

+ Here is the call graph for this function:

◆ __appendTimeTargets()

ilObjectXMLWriter::__appendTimeTargets (   $a_ref_id)

Append time target settings for items inside of courses.

Parameters
int$ref_idReference id of object
Returns
void

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

259 {
260 global $DIC;
261
262 $tree = $DIC['tree'];
263
264 if (!$tree->checkForParentType($a_ref_id, 'crs')) {
265 return;
266 }
267 include_once('./Services/Object/classes/class.ilObjectActivation.php');
268 $time_targets = ilObjectActivation::getItem($a_ref_id);
269
270 switch ($time_targets['timing_type']) {
273 break;
276 break;
279 break;
280 default:
282 break;
283 }
284
285 $this->xmlStartTag('TimeTarget', array('type' => $type));
286
287 # if($type == self::TIMING_TEMPORARILY_AVAILABLE)
288 {
289 $vis = $time_targets['visible'] == 0 ? self::TIMING_VISIBILITY_OFF : self::TIMING_VISIBILITY_ON;
290 $this->xmlElement(
291 'Timing',
292 array('starting_time' => $time_targets['timing_start'],
293 'ending_time' => $time_targets['timing_end'],
294 'visibility' => $vis)
295 );
296
297 }
298 # if($type == self::TIMING_PRESETTING)
299 {
300 $this->xmlElement(
301 'Suggestion',
302 array(
303 'starting_time' => $time_targets['suggestion_start'],
304 'ending_time' => $time_targets['suggestion_end'],
305 'changeable' => $time_targets['changeable'])
306 );
307 }
308 $this->xmlEndTag('TimeTarget');
309 return;
310 }
static getItem($a_ref_id)
Get item data.

References $DIC, $tree, $type, ilObjectActivation\getItem(), TIMING_DEACTIVATED, TIMING_PRESETTING, TIMING_TEMPORARILY_AVAILABLE, TIMING_VISIBILITY_OFF, TIMING_VISIBILITY_ON, ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, ilObjectActivation\TIMINGS_PRESETTING, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ __buildFooter()

ilObjectXMLWriter::__buildFooter ( )

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

395 {
396 $this->xmlEndTag('Objects');
397 }

References ilXmlWriter\xmlEndTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildHeader()

ilObjectXMLWriter::__buildHeader ( )

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

386 {
387 $this->xmlSetDtdDef("<!DOCTYPE Objects PUBLIC \"-//ILIAS//DTD ILIAS Repositoryobjects//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_object_4_0.dtd\">");
388 $this->xmlSetGenCmt("Export of ILIAS objects");
389 $this->xmlHeader();
390 $this->xmlStartTag("Objects");
391 return true;
392 }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

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

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getAccessInfo()

ilObjectXMLWriter::__getAccessInfo ( $object,
  $ref_id 
)

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

400 {
401 global $DIC;
402
403 $ilAccess = $DIC['ilAccess'];
404
405 include_once 'Services/AccessControl/classes/class.ilAccess.php';
406
407 $ilAccess->checkAccessOfUser($this->getUserId(), 'read', 'view', $ref_id, $object->getType(), $object->getId());
408
409 if (!$info = $ilAccess->getInfo()) {
410 return 'granted';
411 } else {
412 return $info[0]['type'];
413 }
414 }

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

+ Here is the call graph for this function:

◆ __getObjects()

ilObjectXMLWriter::__getObjects ( )

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

132 {
133 return $this->objects ? $this->objects : array();
134 }

Referenced by start().

+ Here is the caller graph for this function:

◆ appendPathToObject()

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

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

418 {
419 global $DIC;
420
421 $tree = $DIC['tree'];
422 $lng = $DIC['lng'];
423 $items = $tree->getPathFull($refid);
424 $writer->xmlStartTag("Path");
425 foreach ($items as $item) {
426 if ($item["ref_id"] == $refid) {
427 continue;
428 }
429 if ($item["type"] == "root") {
430 $item["title"] = $lng->txt("repository");
431 }
432 $writer->xmlElement("Element", array("ref_id" => $item["ref_id"], "type" => $item["type"]), $item["title"]);
433 }
434 $writer->xmlEndTag("Path");
435 }
$lng

References $DIC, $lng, and $tree.

Referenced by __appendPath(), and ilSoapRoleObjectXMLWriter\start().

+ Here is the caller graph for this function:

◆ enabledOperations()

ilObjectXMLWriter::enabledOperations ( )

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

References $enable_operations.

Referenced by __appendOperations().

+ Here is the caller graph for this function:

◆ enabledReferences()

ilObjectXMLWriter::enabledReferences ( )

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

References $enable_references.

◆ enableOperations()

ilObjectXMLWriter::enableOperations (   $a_status)

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

102 {
103 $this->enable_operations = $a_status;
104
105 return true;
106 }

◆ enablePermissionCheck()

ilObjectXMLWriter::enablePermissionCheck (   $a_status)

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

83 {
84 $this->check_permission = $a_status;
85 }

◆ enableReferences()

ilObjectXMLWriter::enableReferences (   $a_stat)

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

115 {
116 $this->enable_references = $a_stat;
117 }

◆ getUserId()

ilObjectXMLWriter::getUserId ( )

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

References $user_id.

Referenced by __getAccessInfo().

+ Here is the caller graph for this function:

◆ getXML()

ilObjectXMLWriter::getXML ( )

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

159 {
160 return $this->xmlDumpMem(false);
161 }
xmlDumpMem($format=true)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ isPermissionCheckEnabled()

ilObjectXMLWriter::isPermissionCheckEnabled ( )

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

References $check_permission.

Referenced by start().

+ Here is the caller graph for this function:

◆ setHighlighter()

ilObjectXMLWriter::setHighlighter (   $a_highlighter)

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

76 {
77 $this->highlighter = $a_highlighter;
78 }

◆ setMode()

ilObjectXMLWriter::setMode (   $a_mode)

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

71 {
72 $this->mode = $a_mode;
73 }

◆ setObjects()

ilObjectXMLWriter::setObjects (   $objects)

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

127 {
128 $this->objects = $objects;
129 }

References $objects.

◆ setUserId()

ilObjectXMLWriter::setUserId (   $a_id)

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

93 {
94 $this->user_id = $a_id;
95 }

◆ start()

ilObjectXMLWriter::start ( )

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

137 {
138 global $DIC;
139
140 $ilAccess = $DIC['ilAccess'];
141 $objDefinition = $DIC['objDefinition'];
142
143 $this->__buildHeader();
144
145 foreach ($this->__getObjects() as $object) {
146 if (method_exists($object, 'getType') and $objDefinition->isRBACObject($object->getType())) {
147 if ($this->isPermissionCheckEnabled() and !$ilAccess->checkAccessOfUser($this->getUserId(), 'read', '', $object->getRefId())) {
148 continue;
149 }
150 }
151 $this->__appendObject($object);
152 }
153 $this->__buildFooter();
154
155 return true;
156 }

References $DIC, __buildFooter(), __buildHeader(), __getObjects(), and isPermissionCheckEnabled().

+ Here is the call graph for this function:

Field Documentation

◆ $check_permission

ilObjectXMLWriter::$check_permission = false
protected

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

Referenced by isPermissionCheckEnabled().

◆ $enable_operations

ilObjectXMLWriter::$enable_operations = false

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

Referenced by enabledOperations().

◆ $enable_references

ilObjectXMLWriter::$enable_references = true
private

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

Referenced by enabledReferences().

◆ $highlighter

ilObjectXMLWriter::$highlighter = null
private

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

◆ $ilias

ilObjectXMLWriter::$ilias

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

Referenced by __construct().

◆ $mode

ilObjectXMLWriter::$mode = 0
private

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

◆ $objects

ilObjectXMLWriter::$objects = array()

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

Referenced by __appendOperations(), and setObjects().

◆ $user_id

ilObjectXMLWriter::$user_id = 0

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

Referenced by getUserId().

◆ $xml

ilObjectXMLWriter::$xml

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

◆ MODE_SEARCH_RESULT

const ilObjectXMLWriter::MODE_SEARCH_RESULT = 1

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

◆ 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 33 of file class.ilObjectXMLWriter.php.

Referenced by __appendTimeTargets().

◆ TIMING_VISIBILITY_ON

const ilObjectXMLWriter::TIMING_VISIBILITY_ON = 1

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

Referenced by __appendTimeTargets().


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