ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSoapMailXmlParser 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 ilSoapMailXmlParser:
+ Collaboration diagram for ilSoapMailXmlParser:

Public Member Functions

 __construct (string $a_xml)
 
 getMails ()
 
 start ()
 
 setHandlers ($a_xml_parser)
 Set event handlers. More...
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, string $a_name)
 Handler for end of element. More...
 
 handlerCharacterData ($a_xml_parser, string $a_data)
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Protected Member Functions

 parseName (array $a_attribs)
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Protected Attributes

array $mails = []
 
array $mail = []
 
array $attachment = []
 
array $lines = []
 
string $cdata = ''
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

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 parser for soap mails

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilSoapMailXmlParser::__construct ( string  $a_xml)

Definition at line 32 of file class.ilSoapMailXmlParser.php.

References ILIAS\GlobalScreen\Provider\__construct(), ilSaxParser\setThrowException(), and ilSaxParser\setXMLContent().

33  {
34  parent::__construct('', true);
35  $this->setThrowException(true);
36  $this->setXMLContent($a_xml);
37  }
setThrowException(bool $throw_exception)
__construct(Container $dic, ilPlugin $plugin)
setXMLContent(string $a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ getMails()

ilSoapMailXmlParser::getMails ( )

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

References $mails.

39  : array
40  {
41  return $this->mails;
42  }

◆ handlerBeginTag()

ilSoapMailXmlParser::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)

handler for begin of element

Parameters
XMLParser | resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

Definition at line 66 of file class.ilSoapMailXmlParser.php.

References ILIAS\UI\examples\Symbol\Glyph\Attachment\attachment(), and parseName().

Referenced by setHandlers().

66  : void
67  {
68  switch ($a_name) {
69  case 'Mail':
70  $this->mail = array();
71  $this->mail['usePlaceholders'] = (bool) $a_attribs['usePlaceholders'];
72  $this->mail['type'] = $a_attribs['type'] === 'System' ? 'system' : 'normal';
73  break;
74 
75  case 'To':
76  $this->mail['to'] = $this->parseName($a_attribs);
77  break;
78 
79  case 'Cc':
80  $this->mail['cc'] = $this->parseName($a_attribs);
81  break;
82 
83  case 'Bcc':
84  $this->mail['bcc'] = $this->parseName($a_attribs);
85  break;
86 
87  case 'Subject':
88  break;
89 
90  case 'Message':
91  $this->lines = array();
92  break;
93 
94  case 'Attachment':
95  $this->attachment = array();
96  $this->attachment['name'] = $a_attribs['name'];
97  break;
98  }
99  }
attachment()
description: > Example for rendring a attachment glyph.
Definition: attachment.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerCharacterData()

ilSoapMailXmlParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_data
Returns
void

Definition at line 139 of file class.ilSoapMailXmlParser.php.

Referenced by setHandlers().

139  : void
140  {
141  if ($a_data !== "\n") {
142  // Replace multiple tabs with one space
143  $a_data = preg_replace("/\t+/", " ", $a_data);
144  $this->cdata .= $a_data;
145  }
146  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

ilSoapMailXmlParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

Handler for end of element.

Parameters
XMLParser | resource$a_xml_parserxml parser
string$a_nameelement name

Definition at line 106 of file class.ilSoapMailXmlParser.php.

References $attachment, $cdata, $lines, $mail, and ILIAS\UI\examples\Symbol\Glyph\Attachment\attachment().

Referenced by setHandlers().

106  : void
107  {
108  switch ($a_name) {
109  case 'Mail':
110  $this->mails[] = $this->mail;
111  break;
112 
113  case 'Subject':
114  $this->mail['subject'] = $this->cdata;
115  break;
116 
117  case 'Message':
118  $this->mail['body'] = $this->lines;
119  break;
120 
121  case 'P':
122  $this->lines[] = trim($this->cdata);
123  break;
124 
125  case 'Attachment':
126  $this->attachment['content'] = base64_decode(trim($this->cdata));
127  $this->mail['attachments'][] = $this->attachment;
128  break;
129  }
130 
131  $this->cdata = '';
132  }
attachment()
description: > Example for rendring a attachment glyph.
Definition: attachment.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseName()

ilSoapMailXmlParser::parseName ( array  $a_attribs)
protected

Definition at line 148 of file class.ilSoapMailXmlParser.php.

References ilObjectFactory\getInstanceByObjId().

Referenced by handlerBeginTag().

148  : string
149  {
150  if ($a_attribs['obj_id']) {
151  $il_id = explode('_', $a_attribs['obj_id']);
152  if (!$user = ilObjectFactory::getInstanceByObjId($il_id[3], false)) {
153  throw new InvalidArgumentException("Invalid user id given: obj_id => " . $a_attribs['obj_id']);
154  }
155  return $user->getLogin();
156  }
157  return (string) ($a_attribs['name'] ?? '');
158  }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilSoapMailXmlParser::setHandlers (   $a_xml_parser)

Set event handlers.

Parameters
XMLParser|resourceA reference to the xml parser

Definition at line 54 of file class.ilSoapMailXmlParser.php.

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

54  : void
55  {
56  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
57  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
58  }
handlerCharacterData($a_xml_parser, string $a_data)
handlerEndTag($a_xml_parser, string $a_name)
Handler for end of element.
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
handler for begin of element
+ Here is the call graph for this function:

◆ start()

ilSoapMailXmlParser::start ( )

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

References ilSaxParser\startParsing().

44  : bool
45  {
46  $this->startParsing();
47  return true;
48  }
startParsing()
stores xml data in array
+ Here is the call graph for this function:

Field Documentation

◆ $attachment

array ilSoapMailXmlParser::$attachment = []
protected

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

Referenced by handlerEndTag().

◆ $cdata

string ilSoapMailXmlParser::$cdata = ''
protected

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

Referenced by handlerEndTag().

◆ $lines

array ilSoapMailXmlParser::$lines = []
protected

Definition at line 29 of file class.ilSoapMailXmlParser.php.

Referenced by handlerEndTag().

◆ $mail

array ilSoapMailXmlParser::$mail = []
protected

Definition at line 27 of file class.ilSoapMailXmlParser.php.

Referenced by handlerEndTag().

◆ $mails

array ilSoapMailXmlParser::$mails = []
protected

Definition at line 26 of file class.ilSoapMailXmlParser.php.

Referenced by getMails().


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