[SPIP] ~maj 3.0.10 --> 3.0.14
[lhc/web/www.git] / www / ecrire / iterateur / data.php
index aec48ae..4bd93c4 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2012                                                *
+ *  Copyright (c) 2001-2014                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
@@ -12,6 +12,7 @@
 
 if (!defined('_ECRIRE_INC_VERSION')) return;
 
+if (!defined('_DATA_SOURCE_MAX_SIZE')) define('_DATA_SOURCE_MAX_SIZE',2*1048576);
 
 
 /**
@@ -267,7 +268,7 @@ class IterateurDATA implements Iterator {
                        else {
                                if (preg_match(',^https?://,', $src)) {
                                        include_spip('inc/distant');
-                                       $u = recuperer_page($src);
+                                       $u = recuperer_page($src, false, false, _DATA_SOURCE_MAX_SIZE);
                                        if (!$u)
                                                throw new Exception("404");
                                        if (!isset($ttl)) $ttl = 24*3600;
@@ -385,7 +386,7 @@ class IterateurDATA implements Iterator {
                        if (preg_match(',^\.?([/\w]+)( DESC)?$,iS', ltrim($tri, '/'), $r)) {
                                // tri par cle
                                if ($r[1] == 'cle'){
-                                       if (isset($r2) and $r[2])
+                                       if (isset($r[2]) and $r[2])
                                                krsort($this->tableau);
                                        else
                                                ksort($this->tableau);
@@ -620,6 +621,23 @@ function inc_glob_to_array_dist($u) {
        );
 }
 
+/**
+ * YAML -> tableau
+ * @param string $u
+ * @return bool|array
+ * @throws Exception
+ */
+function inc_yaml_to_array_dist($u){
+       include_spip('inc/yaml-mini');
+       if (!function_exists("yaml_decode")){
+               throw new Exception('YAML: impossible de trouver la fonction yaml_decode');
+               return false;
+       }
+
+       return yaml_decode($u);
+}
+
+
 /**
  * pregfiles -> tableau
  * lister des fichiers a partir d'un dossier de base et selon une regexp.