Changeset 77024 in spip-zone
- Timestamp:
- Oct 6, 2013, 12:03:03 PM (8 years ago)
- Location:
- _plugins_/rainette/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/rainette/trunk/content/debug.html
r70851 r77024 8 8 [(#REM) <!--Fil d'Ariane--> ] 9 9 <p id="hierarchie"><a href="#URL_SITE_SPIP/"><:accueil_site:></a> > <strong class="on"><:rainette:meteo|ucfirst:></strong></p> 10 11 10 12 11 [(#REM) <!--Les informations d'une ville - weather--> ] -
_plugins_/rainette/trunk/inc/convertir.php
r77022 r77024 2 2 3 3 if (!defined("_ECRIRE_INC_VERSION")) return; 4 5 function angle2direction($angle) { 6 static $liste_directions = array( 7 0 => 'N', 8 1 => 'NNE', 9 2 => 'NE', 10 3 => 'ENE', 11 4 => 'E', 12 5 => 'ESE', 13 6 => 'SE', 14 7 => 'SSE', 15 8 => 'S', 16 9 => 'SSW', 17 10 => 'SW', 18 11 => 'WSW', 19 12 => 'W', 20 13 => 'WNW', 21 14 => 'NW', 22 15 => 'NNW', 23 16 => 'N', 24 17 => 'V' 25 ); 26 27 $direction = ''; 28 if (is_int($angle)) 29 $direction = $liste_directions[round($angle / 22.5) % 16]; 30 elseif (in_array(strtoupper($angle), $liste_directions)) 31 $direction = strtoupper($angle); 32 33 return $direction; 34 } 4 35 5 36 /** -
_plugins_/rainette/trunk/inc/phraser.php
r70837 r77024 15 15 $convertir = charger_fonction('simplexml_to_array', 'inc'); 16 16 $xml = $convertir(simplexml_load_string($flux), $utiliser_namespace); 17 $xml = $xml['root']; 17 18 18 19 return $xml; -
_plugins_/rainette/trunk/inc/simplexml_to_array.php
r70855 r77024 1 1 <?php 2 /** 3 * Ce fichier contient la fonction surchargeable de transformation d'un XML en tableau PHP. 4 * Cette fonction est une réplication de la fonction homonyme de SPIP. Elle est dupliquée 5 * dans le plugin car la fonction SPIP n'est disponible qu'à partir de la version 3.0.10. 6 * 7 * @package SPIP\BOUSSOLE\Outils\XML 8 */ 9 2 10 3 11 if (!defined("_ECRIRE_INC_VERSION")) return; … … 5 13 6 14 /** 7 * Transform e un objet SimpleXML en tableau PHP15 * Transformation d'un texte XML ou d'un objet *SimpleXML* en tableau PHP. 8 16 * 9 * @param object $obj 17 * Si l'argument XML est un texte, il est au préalable converti en objet *SimpleXML* 18 * par la fonction `simplexml_load_string()`. Ensuite, c'est l'objet *SimpleXML* qui est 19 * traduit en tableau PHP à partir de la fonction `xmlObjToArr()`. 20 * 21 * @uses xmlObjToArr() 22 * @example 23 * ``` 24 * $page = recuperer_page($action); 25 * $convertir = charger_fonction('simplexml_to_array', 'inc'); 26 * $tableau = $convertir(simplexml_load_string($page), false); 27 * 28 * ou 29 * 30 * $tableau = $convertir($page, false); 31 * ``` 32 * 33 * @param string|object $xml 34 * XML à phraser et à transformer en tableau PHP. Le XML peut être fourni : 35 * 36 * - soit comme une chaine de caractères représentant le texte XML lui-même, 37 * - soit comme un objet XML produit à partir du texte par la fonction 38 * `simplexml_load_string()` de PHP. 39 * @param bool $utiliser_namespace 40 * Indicateur d'utilisation des namespaces dans le XML. Si aucun namespace n'est 41 * utilisé dans le XML, il est préférable de forcer l'argument à `false` afin 42 * d'éviter l'appel à la fonction `getDocNamespaces()`. 43 * @return array 44 */ 45 function inc_simplexml_to_array_dist($xml, $utiliser_namespace=false){ 46 // Décoder la chaine en SimpleXML si pas deja fait 47 if (is_string($xml)) 48 $xml = simplexml_load_string($xml); 49 return array('root'=>@xmlObjToArr($xml, $utiliser_namespace)); 50 } 51 52 53 /** 54 * Transformation d'un objet *SimpleXML* en tableau PHP. 55 * 56 * @autor xaviered at gmail dot com 17-May-2012 07:00 57 * 58 * @param object $objet_xml 59 * Objet *SimpleXML* à phraser et à transformer en tableau PHP. 60 * @param bool $utiliser_namespace 61 * Indicateur d'utilisation des namespaces dans le XML. Si aucun namespace n'est 62 * utilisé dans le XML, il est préférable de forcer l'argument à `false` afin 63 * d'éviter l'appel à la fonction getDocNamespaces()`. 10 64 * @return array 11 65 **/ 12 // http://www.php.net/manual/pt_BR/book.simplexml.php#108688 13 // xaviered at gmail dot com 17-May-2012 07:00 14 function inc_simplexml_to_array($obj, $utiliser_namespace='false') { 66 function xmlObjToArr($objet_xml, $utiliser_namespace=false) { 15 67 16 68 $tableau = array(); … … 18 70 // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc 19 71 // de l'activer ou pas suivant le contenu supposé du XML 20 if (is_object($obj)) { 21 if ($utiliser_namespace) 22 $namespace = $obj->getDocNamespaces(true); 23 $namespace[NULL] = NULL; 72 if (is_object($objet_xml)) { 73 if (is_array($utiliser_namespace)){ 74 $namespace = $utiliser_namespace; 75 } 76 else { 77 if ($utiliser_namespace) 78 $namespace = $objet_xml->getDocNamespaces(true); 79 $namespace[NULL] = NULL; 80 } 24 81 25 $name = strtolower((string)$obj ->getName());26 $text = trim((string)$obj );82 $name = strtolower((string)$objet_xml->getName()); 83 $text = trim((string)$objet_xml); 27 84 if (strlen($text) <= 0) { 28 85 $text = NULL; … … 35 92 foreach( $namespace as $ns=>$nsUrl ) { 36 93 // attributes 37 $objAttributes = $obj ->attributes($ns, true);94 $objAttributes = $objet_xml->attributes($ns, true); 38 95 foreach( $objAttributes as $attributeName => $attributeValue ) { 39 96 $attribName = strtolower(trim((string)$attributeName)); … … 46 103 47 104 // children 48 $objChildren = $obj ->children($ns, true);105 $objChildren = $objet_xml->children($ns, true); 49 106 foreach( $objChildren as $childName=>$child ) { 50 107 $childName = strtolower((string)$childName); … … 52 109 $childName = $ns.':'.$childName; 53 110 } 54 $children[$childName][] = inc_simplexml_to_array($child);111 $children[$childName][] = xmlObjToArr($child, $namespace); 55 112 } 56 113 } … … 58 115 $tableau = array( 59 116 'name'=>$name, 60 'text'=>$text,61 'attributes'=>$attributes,62 'children'=>$children63 117 ); 118 if ($text) 119 $tableau['text'] = $text; 120 if ($attributes) 121 $tableau['attributes'] = $attributes; 122 if ($children) 123 $tableau['children'] = $children; 64 124 } 65 125 -
_plugins_/rainette/trunk/modeles/infos_ville.html
r76798 r77024 6 6 <div class="rainette_infos"> 7 7 <h2 class="ville">[(#ENV{ville})]</h2> 8 < divclass="coordonnees">8 <ul class="coordonnees"> 9 9 <li><:rainette:longitude|ucfirst:> :[ (#ENV{longitude}|rainette_afficher_unite{angle, 2})</li>] 10 10 <li><:rainette:latitude|ucfirst:> :[ (#ENV{latitude}|rainette_afficher_unite{angle, 2})</li>] 11 11 [<li><:rainette:population|ucfirst:> : (#ENV{population}|rainette_afficher_unite{population})</li>] 12 12 [<li><:rainette:region|ucfirst:> : (#ENV{region})</li>] 13 </ div>13 </ul> 14 14 15 15 #INCLURE{fond=modeles/inc-credits, -
_plugins_/rainette/trunk/paquet.xml
r76798 r77024 2 2 prefix="rainette" 3 3 categorie="divers" 4 version="2.0.1 7"4 version="2.0.18" 5 5 etat="dev" 6 6 compatibilite="[3.0.0;3.*]" … … 15 15 <auteur lien="http://blog.smellup.net">Eric Lupinacci</auteur> 16 16 <auteur>Cedric Morin</auteur> 17 <credit>Touti, pour le plugin Grenouille</credit> 17 18 18 19 <licence lien="http://www.gnu.org/licenses/gpl-3.0.html">GPL 3</licence> -
_plugins_/rainette/trunk/rainette_fonctions.php
r77022 r77024 95 95 */ 96 96 function rainette_afficher_direction($direction) { 97 static $liste_direction = array( 98 0 => 'N', 99 1 => 'NNE', 100 2 => 'NE', 101 3 => 'ENE', 102 4 => 'E', 103 5 => 'ESE', 104 6 => 'SE', 105 7 => 'SSE', 106 8 => 'S', 107 9 => 'SSW', 108 10 => 'SW', 109 11 => 'WSW', 110 12 => 'W', 111 13 => 'WNW', 112 14 => 'NW', 113 15 => 'NNW', 114 16 => 'N', 115 17 => 'V' 116 ); 117 118 if (is_int($direction)) 119 $direction = $liste_direction[round($direction / 22.5) % 16]; 120 elseif (!in_array($direction, $liste_direction)) 97 98 include_spip('inc/convertir'); 99 $direction = angle2direction($direction); 100 101 if ($direction) 102 return _T('rainette:direction_'.$direction); 103 else 121 104 return _T('rainette:valeur_indeterminee'); 122 return _T('rainette:direction_'.$direction);123 105 } 124 106
Note: See TracChangeset
for help on using the changeset viewer.