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

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

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 17 of file class.ilSoapMailXmlParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilSoapMailXmlParser::__construct ( string  $a_xml)

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

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

26  {
27  parent::__construct('', true);
28  $this->setThrowException(true);
29  $this->setXMLContent($a_xml);
30  }
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 32 of file class.ilSoapMailXmlParser.php.

References $mails.

32  : array
33  {
34  return $this->mails;
35  }

◆ 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 60 of file class.ilSoapMailXmlParser.php.

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

60  : void
61  {
62  switch ($a_name) {
63  case 'Mail':
64  $this->mail = array();
65  $this->mail['usePlaceholders'] = (bool) $a_attribs['usePlaceholders'];
66  $this->mail['type'] = $a_attribs['type'] === 'System' ? 'system' : 'normal';
67  break;
68 
69  case 'To':
70  $this->mail['to'] = $this->parseName($a_attribs);
71  break;
72 
73  case 'Cc':
74  $this->mail['cc'] = $this->parseName($a_attribs);
75  break;
76 
77  case 'Bcc':
78  $this->mail['bcc'] = $this->parseName($a_attribs);
79  break;
80 
81  case 'Subject':
82  break;
83 
84  case 'Message':
85  $this->lines = array();
86  break;
87 
88  case 'Attachment':
89  $this->attachment = array();
90  $this->attachment['name'] = $a_attribs['name'];
91  break;
92 
93  }
94  }
+ Here is the call 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 134 of file class.ilSoapMailXmlParser.php.

134  : void
135  {
136  if ($a_data !== "\n") {
137  // Replace multiple tabs with one space
138  $a_data = preg_replace("/\t+/", " ", $a_data);
139  $this->cdata .= $a_data;
140  }
141  }

◆ 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 101 of file class.ilSoapMailXmlParser.php.

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

101  : void
102  {
103  switch ($a_name) {
104  case 'Mail':
105  $this->mails[] = $this->mail;
106  break;
107 
108  case 'Subject':
109  $this->mail['subject'] = $this->cdata;
110  break;
111 
112  case 'Message':
113  $this->mail['body'] = $this->lines;
114  break;
115 
116  case 'P':
117  $this->lines[] = trim($this->cdata);
118  break;
119 
120  case 'Attachment':
121  $this->attachment['content'] = base64_decode(trim($this->cdata));
122  $this->mail['attachments'][] = $this->attachment;
123  break;
124  }
125 
126  $this->cdata = '';
127  }
+ Here is the call graph for this function:

◆ parseName()

ilSoapMailXmlParser::parseName ( array  $a_attribs)
protected

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

References ilObjectFactory\getInstanceByObjId().

Referenced by handlerBeginTag().

143  : string
144  {
145  if ($a_attribs['obj_id']) {
146  $il_id = explode('_', $a_attribs['obj_id']);
147  if (!$user = ilObjectFactory::getInstanceByObjId($il_id[3], false)) {
148  throw new InvalidArgumentException("Invalid user id given: obj_id => " . $a_attribs['obj_id']);
149  }
150  return $user->getLogin();
151  }
152  return (string) ($a_attribs['name'] ?? '');
153  }
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 47 of file class.ilSoapMailXmlParser.php.

47  : void
48  {
49  xml_set_object($a_xml_parser, $this);
50  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
51  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
52  }

◆ start()

ilSoapMailXmlParser::start ( )

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

References ilSaxParser\startParsing().

37  : bool
38  {
39  $this->startParsing();
40  return true;
41  }
startParsing()
stores xml data in array
+ Here is the call graph for this function:

Field Documentation

◆ $attachment

array ilSoapMailXmlParser::$attachment = []
protected

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

Referenced by handlerEndTag().

◆ $cdata

string ilSoapMailXmlParser::$cdata = ''
protected

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

Referenced by handlerEndTag().

◆ $lines

array ilSoapMailXmlParser::$lines = []
protected

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

Referenced by handlerEndTag().

◆ $mail

array ilSoapMailXmlParser::$mail = []
protected

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

Referenced by handlerEndTag().

◆ $mails

array ilSoapMailXmlParser::$mails = []
protected

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

Referenced by getMails().


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