Subversion Repositories ALCASAR

Rev

Rev 2770 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 3037
Line 26... Line 26...
26
class SimpleXMLExtended
26
class SimpleXMLExtended
27
{
27
{
28
    /**
28
    /**
29
     * store the encoding that is used for conversation to utf8
29
     * store the encoding that is used for conversation to utf8
30
     *
30
     *
31
     * @var String base encoding
31
     * @var string base encoding
32
     */
32
     */
33
    private $_encoding = null;
33
    private $_encoding = null;
34
 
34
 
35
    /**
35
    /**
36
     * SimpleXMLElement to which every call is delegated
36
     * SimpleXMLElement to which every call is delegated
Line 137... Line 137...
137
     * add a attribute to a child and convert name and value to utf8
137
     * add a attribute to a child and convert name and value to utf8
138
     *
138
     *
139
     * @param String $name  name of the attribute
139
     * @param String $name  name of the attribute
140
     * @param String $value value of the attribute
140
     * @param String $value value of the attribute
141
     *
141
     *
142
     * @return Void
142
     * @return void
143
     */
143
     */
144
    public function addAttribute($name, $value)
144
    public function addAttribute($name, $value)
145
    {
145
    {
146
        $nameUtf8 = $this->_toUTF8($name);
146
        $nameUtf8 = $this->_toUTF8($name);
147
        $valueUtf8 = htmlspecialchars($this->_toUTF8($value), ENT_COMPAT, "UTF-8");
147
        $valueUtf8 = htmlspecialchars($this->_toUTF8($value), ENT_COMPAT, "UTF-8");
Line 155... Line 155...
155
    /**
155
    /**
156
     * append a xml-tree to another xml-tree
156
     * append a xml-tree to another xml-tree
157
     *
157
     *
158
     * @param SimpleXMLElement $new_child child that should be appended
158
     * @param SimpleXMLElement $new_child child that should be appended
159
     *
159
     *
160
     * @return Void
160
     * @return void
161
     */
161
     */
162
    public function combinexml(SimpleXMLElement $new_child)
162
    public function combinexml(SimpleXMLElement $new_child)
163
    {
163
    {
164
        $node1 = dom_import_simplexml($this->_SimpleXmlElement);
164
        $node1 = dom_import_simplexml($this->_SimpleXmlElement);
165
        $dom_sxe = dom_import_simplexml($new_child);
165
        $dom_sxe = dom_import_simplexml($new_child);
Line 174... Line 174...
174
     *
174
     *
175
     * @return String UTF-8 string
175
     * @return String UTF-8 string
176
     */
176
     */
177
    private function _toUTF8($str)
177
    private function _toUTF8($str)
178
    {
178
    {
179
        $str = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', ' ', $str)); //remove nonprintable characters
179
        $str = trim(preg_replace('/[\x00-\x09\x0b-\x1F]/', ' ', strval($str))); //remove nonprintable characters
180
        if ($this->_encoding != null) {
180
        if ($this->_encoding != null) {
181
            if (strcasecmp($this->_encoding, "UTF-8") == 0) {
181
            if (strcasecmp($this->_encoding, "UTF-8") == 0) {
182
                return $str;
182
                return $str;
183
            } elseif (strcasecmp($this->_encoding, "CP437") == 0) {
183
            } elseif (strcasecmp($this->_encoding, "CP437") == 0) {
184
                $strr = "";
184
                $strr = "";