From 303d942d96dff2c5e33fd45d92a52977ec35895d Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Sat, 6 Jul 2013 14:24:28 +0000
Subject: [PATCH] =?UTF-8?q?Report=20de=20r20699=20:=20Reparer=20inc=5Fsimp?=
 =?UTF-8?q?lexml=5Fto=5Farray=20qui=20re=C3=A7oit=20de=20(DATA)=20une=20st?=
 =?UTF-8?q?ring=20et=20non=20un=20Object=20La=20fonction=20se=20charge=20d?=
 =?UTF-8?q?onc=20de=20charger=20le=20xml=20via=20simplexml=20et=20le=20pas?=
 =?UTF-8?q?se=20a=20xmlObjToArr=20qui=20fait=20la=20decomposition=20en=20t?=
 =?UTF-8?q?ableau=20+=20PHPDoc?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/simplexml_to_array.php | 35 ++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/ecrire/inc/simplexml_to_array.php b/ecrire/inc/simplexml_to_array.php
index 142b858e7e..a89f468a57 100644
--- a/ecrire/inc/simplexml_to_array.php
+++ b/ecrire/inc/simplexml_to_array.php
@@ -1,17 +1,42 @@
 <?php
 
-if (!defined("_ECRIRE_INC_VERSION")) return;
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2013                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined('_ECRIRE_INC_VERSION')) return;
+
+
+
+
+/**
+ * Transforme un texte XML en tableau PHP
+ * @param  string $u
+ * @param bool $utiliser_namespace
+ * @return array
+ */
+function inc_simplexml_to_array_dist($u, $utiliser_namespace=false){
+	$u = simplexml_load_string($u);
+	return array('root'=>@xmlObjToArr($u, $utiliser_namespace));
+}
 
 
 /**
  * Transforme un objet SimpleXML en tableau PHP
+ * http://www.php.net/manual/pt_BR/book.simplexml.php#108688
+ * xaviered at gmail dot com 17-May-2012 07:00
  *
  * @param object $obj
+ * @param bool $utiliser_namespace
  * @return array
 **/
-// http://www.php.net/manual/pt_BR/book.simplexml.php#108688
-// xaviered at gmail dot com 17-May-2012 07:00
-function inc_simplexml_to_array_dist($obj, $utiliser_namespace='false') {
+function xmlObjToArr($obj, $utiliser_namespace=false) {
 
 	$tableau = array();
 
@@ -51,7 +76,7 @@ function inc_simplexml_to_array_dist($obj, $utiliser_namespace='false') {
 				if( !empty($ns) ) {
 					$childName = $ns.':'.$childName;
 				}
-				$children[$childName][] = inc_simplexml_to_array_dist($child);
+				$children[$childName][] = xmlObjToArr($child);
 			}
 		}
 
-- 
GitLab