ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSoapRoleObjectXMLWriter Class Reference

XML writer class Class to simplify manual writing of xml documents. More...

+ Inheritance diagram for ilSoapRoleObjectXMLWriter:
+ Collaboration diagram for ilSoapRoleObjectXMLWriter:

Public Member Functions

 __construct ()
 
 setObjects (array $roles)
 
 setType (string $type)
 
 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...
 

Data Fields

string $xml = ''
 

Private Member Functions

 buildHeader ()
 
 buildFooter ()
 

Private Attributes

array $roles = []
 
string $role_type = ''
 

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
class.ilObjectXMLWriter.php,v 1.3 2005/11/04 12:50:24 smeyer Exp

Definition at line 15 of file class.ilSoapRoleObjectXMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilSoapRoleObjectXMLWriter::__construct ( )

Definition at line 21 of file class.ilSoapRoleObjectXMLWriter.php.

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

22  {
23  global $DIC;
24 
25  $ilUser = $DIC->user();
26 
28  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

Member Function Documentation

◆ buildFooter()

ilSoapRoleObjectXMLWriter::buildFooter ( )
private

Definition at line 116 of file class.ilSoapRoleObjectXMLWriter.php.

References ilXmlWriter\xmlEndTag().

Referenced by start().

116  : void
117  {
118  $this->xmlEndTag('Roles');
119  }
xmlEndTag(string $tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildHeader()

ilSoapRoleObjectXMLWriter::buildHeader ( )
private

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

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

Referenced by start().

108  : void
109  {
110  $this->xmlSetDtdDef("<!DOCTYPE Roles PUBLIC \"-//ILIAS//DTD ILIAS Roles//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_role_object_3_10.dtd\">");
111  $this->xmlSetGenCmt("Roles information of ilias system");
112  $this->xmlHeader();
113  $this->xmlStartTag('Roles');
114  }
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:

◆ getXML()

ilSoapRoleObjectXMLWriter::getXML ( )

Definition at line 103 of file class.ilSoapRoleObjectXMLWriter.php.

References ilXmlWriter\xmlDumpMem().

103  : string
104  {
105  return $this->xmlDumpMem(false);
106  }
xmlDumpMem(bool $format=true)
Returns xml document from memory.
+ Here is the call graph for this function:

◆ setObjects()

ilSoapRoleObjectXMLWriter::setObjects ( array  $roles)

Definition at line 30 of file class.ilSoapRoleObjectXMLWriter.php.

References $roles.

30  : void
31  {
32  $this->roles = $roles;
33  }

◆ setType()

ilSoapRoleObjectXMLWriter::setType ( string  $type)

Definition at line 35 of file class.ilSoapRoleObjectXMLWriter.php.

References $type.

35  : void
36  {
37  $this->role_type = $type;
38  }
$type

◆ start()

ilSoapRoleObjectXMLWriter::start ( )

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

References $DIC, $ref_id, ilUtil\__extractRefId(), ilObjRole\_getTranslation(), ilObjectXMLWriter\appendPathToObject(), buildFooter(), buildHeader(), ilObjectFactory\getInstanceByRefId(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

40  : bool
41  {
42  global $DIC;
43 
44  $rbacreview = $DIC['rbacreview'];
45  if ($this->roles === []) {
46  return false;
47  }
48 
49  $this->buildHeader();
50 
51  include_once './Services/AccessControl/classes/class.ilObjRole.php';
52  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
53 
54  foreach ($this->roles as $role) {
55  // if role type is not empty and does not match, then continue;
56  if (!empty($this->role_type) && strcasecmp($this->role_type, $role["role_type"]) !== 0) {
57  continue;
58  }
59  if ($rbacreview->isRoleDeleted($role["obj_id"])) {
60  continue;
61  }
62 
63  $attrs = [
64  'role_type' => ucwords($role["role_type"]),
65  'id' => "il_" . IL_INST_ID . "_role_" . $role["obj_id"]
66  ];
67 
68  $this->xmlStartTag("Role", $attrs);
69  $this->xmlElement('Title', null, $role["title"]);
70  $this->xmlElement('Description', null, $role["description"]);
71  $this->xmlElement('Translation', null, ilObjRole::_getTranslation($role["title"]));
72 
73  if ($ref_id = ilUtil::__extractRefId($role["title"])) {
74  $ownerObj = ilObjectFactory::getInstanceByRefId($ref_id, false);
75 
76  if (is_object($ownerObj)) {
77  $attrs = [
78  "obj_id" => implode(
79  '_',
80  [
81  "il",
82  IL_INST_ID,
83  $ownerObj->getType(),
84  $ownerObj->getId()
85  ]
86  ),
87  "ref_id" => $ownerObj->getRefId(),
88  "type" => $ownerObj->getType()
89  ];
90  $this->xmlStartTag('AssignedObject', $attrs);
91  $this->xmlElement('Title', null, $ownerObj->getTitle());
92  $this->xmlElement('Description', null, $ownerObj->getDescription());
94  $this->xmlEndTag('AssignedObject');
95  }
96  }
97  $this->xmlEndTag("Role");
98  }
99  $this->buildFooter();
100  return true;
101  }
const IL_INST_ID
Definition: constants.php:40
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static _getTranslation(string $a_role_title)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference 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)
static appendPathToObject(ilXmlWriter $writer, int $refid)
static __extractRefId(string $role_title)
extract ref id from role title, e.g.
+ Here is the call graph for this function:

Field Documentation

◆ $role_type

string ilSoapRoleObjectXMLWriter::$role_type = ''
private

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

◆ $roles

array ilSoapRoleObjectXMLWriter::$roles = []
private

Definition at line 18 of file class.ilSoapRoleObjectXMLWriter.php.

Referenced by setObjects().

◆ $xml

string ilSoapRoleObjectXMLWriter::$xml = ''

Definition at line 17 of file class.ilSoapRoleObjectXMLWriter.php.


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