[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / textwheel / wheels / spip / spip-listes.php
index 2e37d65..ad61095 100644 (file)
@@ -1,26 +1,28 @@
 <?php
 
-if (!defined('_ECRIRE_INC_VERSION')) return;
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
 # not useful as this file is included by the engine itself
 # require_once 'engine/textwheel.php';
 
-function tw_liste_init($t){
+function tw_liste_init($t) {
        charger_fonction('dummy', 'inc', true); // ne sert a rien mais evite un segmentation fault PHP, on dirait
-       return tw_liste_item($t,'init');
+       return tw_liste_item($t, 'init');
 }
 
-function tw_liste_close($t){
-       return tw_liste_item($t,'close');
+function tw_liste_close($t) {
+       return tw_liste_item($t, 'close');
 }
 
-function tw_liste_item($t,$quoi='item'){
+function tw_liste_item($t, $quoi = 'item') {
        global $class_spip, $class_spip_plus;
        static $niveau;
        static $pile_li;
        static $pile_type;
        static $type;
 
-       switch ($quoi){
+       switch ($quoi) {
                case 'init':
                        $niveau = 0;
                        $pile_li = array();
@@ -33,7 +35,7 @@ function tw_liste_item($t,$quoi='item'){
                        while ($niveau > 0) {
                                $ajout .= $pile_li[$niveau];
                                $ajout .= $pile_type[$niveau];
-                               $niveau --;
+                               $niveau--;
                        }
                        $t .= $ajout;
                        break;
@@ -42,31 +44,35 @@ function tw_liste_item($t,$quoi='item'){
                case 'ol':
                        $nouv_type = $quoi;
                        break;
-               
+
                case 'item':
                default:
                        $profond = 0;
-                       if ($l=strlen($t[2])) {
-                               $profond=$l;$nouv_type='ul';
-                               if (strncmp($t[2],'#',1)==0) $nouv_type='ol';
+                       if ($l = strlen($t[2])) {
+                               $profond = $l;
+                               $nouv_type = 'ul';
+                               if (strncmp($t[2], '#', 1) == 0) {
+                                       $nouv_type = 'ol';
+                               }
                        }
 
                        if ($profond > 0) {
-                               $ajout='';
+                               $ajout = '';
 
                                // changement de type de liste au meme niveau : il faut
                                // descendre un niveau plus bas, fermer ce niveau, et
                                // remonter
-                               $change_type = ($type AND ($type <> $nouv_type) AND ($profond == $niveau)) ? 1 : 0;
+                               $change_type = ($type and ($type <> $nouv_type) and ($profond == $niveau)) ? 1 : 0;
                                $type = $nouv_type;
 
                                // d'abord traiter les descentes
                                while ($niveau > $profond - $change_type) {
                                        $ajout .= $pile_li[$niveau];
                                        $ajout .= $pile_type[$niveau];
-                                       if (!$change_type)
-                                               unset ($pile_li[$niveau]);
-                                       $niveau --;
+                                       if (!$change_type) {
+                                               unset($pile_li[$niveau]);
+                                       }
+                                       $niveau--;
                                }
 
                                // puis les identites (y compris en fin de descente)
@@ -76,24 +82,27 @@ function tw_liste_item($t,$quoi='item'){
 
                                // puis les montees (y compris apres une descente un cran trop bas)
                                while ($niveau < $profond) {
-                                       if ($niveau == 0)
+                                       if ($niveau == 0) {
                                                $ajout .= "\n\n";
-                                       elseif (!isset($pile_li[$niveau])) {
+                                       elseif (!isset($pile_li[$niveau])) {
                                                $ajout .= "<li$class_spip>";
                                                $pile_li[$niveau] = "</li>";
                                        }
-                                       $niveau ++;
+                                       $niveau++;
                                        $ajout .= "<$type$class_spip_plus>";
                                        $pile_type[$niveau] = "</$type>";
                                }
 
                                $ajout .= "<li$class_spip>";
                                $pile_li[$profond] = "</li>";
-                       }
-                       else {
-                               $ajout = $t[1]; // puce normale ou <hr>
+                       } else {
+                               $ajout = $t[1];  // puce normale ou <hr>
                        }
 
+                       if (!isset($t[3]) or (trim($t[3]) === '')) {
+                               // Permet de gerer la previsualisation grand ecran en temps reel en affichant correctement la derniere puce n'ayant pas encore de texte
+                               $t[3] = '&nbsp;';
+                       }
                        $t = $ajout . $t[3];
                        break;
        }
@@ -101,7 +110,8 @@ function tw_liste_item($t,$quoi='item'){
        return $t;
 }
 
-function tw_def_wrap($t){
+function tw_def_wrap($t) {
        global $class_spip_plus;
+
        return "<dl$class_spip_plus>\n$t</dl>\n";
 }