ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
String.php
Go to the documentation of this file.
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4
5// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6
40// }}}
41
42// dependencies {{{
43require_once 'XML/RPC2/Exception.php';
44require_once 'XML/RPC2/Backend/Php/Value/Scalar.php';
45// }}}
46
58{
59
60 // {{{ constructor
61
67 public function __construct($nativeValue)
68 {
69 $this->setScalarType('string');
70 $this->setNativeValue($nativeValue);
71 }
72
73 // }}}
74 // {{{ encode()
75
81 public function encode()
82 {
83 return '<string>' . strtr($this->getNativeValue(),array('&' => '&amp;', '<' => '&lt;' , '>' => '&gt;')) . '</string>';
84 }
85
86 // }}}
87 // {{{ decode()
88
94 public static function decode($xml)
95 {
96 /* Stupid way of testing for the presence of string element. I don't know another one.
97 At least got rid of the xpath and consequent reparsing of the XML
98 */
99 if ($xml->string->asXML() === FALSE) {
100 return (string) $xml;
101 } else {
102 return (string) $xml->string;
103 }
104 }
105
106 // }}}
107
108}
109
110?>
setScalarType($value)
scalarType property setter
Definition: Scalar.php:77
encode()
Encode the instance into XML, for transport.
Definition: String.php:81
static decode($xml)
Decode transport XML and set the instance value accordingly.
Definition: String.php:94
__construct($nativeValue)
Constructor.
Definition: String.php:67
setNativeValue($value)
nativeValue setter
Definition: Value.php:89
getNativeValue()
nativeValue property getter
Definition: Value.php:76