X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fecrire%2Fplugins%2Finfos_paquet.php;h=039403aeae9606e0b25946eeda8c40c036f88a8b;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=55c793b2121d6d974995fe358c40134d40660b91;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/ecrire/plugins/infos_paquet.php b/www/ecrire/plugins/infos_paquet.php index 55c793b2..039403ae 100644 --- a/www/ecrire/plugins/infos_paquet.php +++ b/www/ecrire/plugins/infos_paquet.php @@ -3,14 +3,16 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2016 * + * Copyright (c) 2001-2017 * * 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; +if (!defined('_ECRIRE_INC_VERSION')) { + return; +} /** * lecture d'un texte conforme a la DTD paquet.dtd @@ -31,23 +33,26 @@ function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { $valider_xml = charger_fonction('valider', 'xml'); $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', "utf-8"); - if (!$vxml->err){ + if (!$vxml->err) { // On veut toutes les variantes selon la version de SPIP - if (!$plug) + if (!$plug) { return $vxml->versions; + } // compatibilite avec l'existant: $tree = $vxml->versions['0']; // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. - if (isset($tree['']) and !strlen($tree[''])) + if (isset($tree['']) and !strlen($tree[''])) { unset($tree['']); + } - $tree['slogan'] = $tree['prefix']."_slogan"; - $tree['description'] = $tree['prefix']."_description"; + $tree['slogan'] = $tree['prefix'] . "_slogan"; + $tree['description'] = $tree['prefix'] . "_description"; paquet_readable_files($tree, "$dir_plugins$plug/"); - if (!$tree['chemin']) - $tree['chemin'] = array(array('path' => '')); // initialiser par defaut + if (!$tree['chemin']) { + $tree['chemin'] = array(array('path' => '')); + } // initialiser par defaut // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans // la structure d'infos du paquet en fonction de la version spip courante @@ -55,12 +60,14 @@ function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { $vspip = $GLOBALS['spip_version_branche']; foreach ($vxml->versions as $_compatibilite => $_version) { if (($_version['balise'] == 'spip') - AND (plugin_version_compatible($_compatibilite, $vspip,'spip'))) { + and (plugin_version_compatible($_compatibilite, $vspip, 'spip')) + ) { // on merge les sous-balises de la balise spip compatible avec celles de la // balise paquet foreach ($_version as $_index => $_balise) { - if ($_index AND $_index != 'balise') - $tree[$_index] =array_merge($tree[$_index], $_balise); + if ($_index and $_index != 'balise') { + $tree[$_index] = array_merge($tree[$_index], $_balise); + } } } } @@ -71,12 +78,13 @@ function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { // Prendre les messages d'erreur sans les numeros de lignes $msg = array_map('array_shift', $vxml->err); // Construire le lien renvoyant sur l'application du validateur XML - $h = $GLOBALS['meta']['adresse_site'].'/' - .substr("$dir_plugins$plug/", strlen(_DIR_RACINE)).'paquet.xml'; + $h = $GLOBALS['meta']['adresse_site'] . '/' + . substr("$dir_plugins$plug/", strlen(_DIR_RACINE)) . 'paquet.xml'; $h = generer_url_ecrire('valider_xml', "var_url=$h"); $t = _T('plugins_erreur', array('plugins' => $plug)); array_unshift($msg, "$t"); + return array('erreur' => $msg); } @@ -88,12 +96,12 @@ function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { * @param string $dir * @return void */ -function paquet_readable_files(&$tree, $dir){ +function paquet_readable_files(&$tree, $dir) { $prefix = strtolower($tree['prefix']); - $tree['options'] = (is_readable($dir.$f = ($prefix.'_options.php'))) ? array($f) : array(); - $tree['fonctions'] = (is_readable($dir.$f = ($prefix.'_fonctions.php'))) ? array($f) : array(); - $tree['install'] = (is_readable($dir.$f = ($prefix.'_administrations.php'))) ? array($f) : array(); + $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? array($f) : array(); + $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? array($f) : array(); + $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? array($f) : array(); } /** @@ -111,13 +119,14 @@ function paquet_readable_files(&$tree, $dir){ */ function paquet_debutElement($phraseur, $name, $attrs) { xml_debutElement($phraseur, $name, $attrs); - if ($phraseur->err) return; - if (($name=='paquet') OR ($name=='spip')){ - if ($name=='spip'){ + if ($phraseur->err) { + return; + } + if (($name == 'paquet') or ($name == 'spip')) { + if ($name == 'spip') { $n = $attrs['compatibilite']; $attrs = array(); - } - else { + } else { $n = '0'; $phraseur->contenu['paquet'] = $attrs; $attrs['menu'] = array(); @@ -128,12 +137,15 @@ function paquet_debutElement($phraseur, $name, $attrs) { $attrs['procure'] = array(); $attrs['pipeline'] = array(); $attrs['utilise'] = array(); + $attrs['style'] = array(); + $attrs['script'] = array(); + $attrs['genie'] = array(); } $phraseur->contenu['compatible'] = $n; $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; - } - else + } else { $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; + } $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; } @@ -142,12 +154,14 @@ function paquet_debutElement($phraseur, $name, $attrs) { * et memoriser les attributs dans le tableau avec l'oppose de la profondeur * comme index, avec '' comme sous-index (les autres sont les attributs) * - * @param pbject $phraseur + * @param object $phraseur * @param string $data */ function paquet_textElement($phraseur, $data) { xml_textElement($phraseur, $data); - if ($phraseur->err OR !(trim($data))) return; + if ($phraseur->err or !(trim($data))) { + return; + } $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; } @@ -160,10 +174,12 @@ function paquet_textElement($phraseur, $data) { * @param string $name */ function paquet_finElement($phraseur, $name) { - if ($phraseur->err) return; + if ($phraseur->err) { + return; + } $n = $phraseur->contenu['compatible']; - if (isset($phraseur->versions[$n][$name][0]) AND is_array($phraseur->versions[$n][$name][0])){ + if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) { $attrs = $phraseur->versions[$n][$name][0]; unset($phraseur->versions[$n][$name][0]); } else { @@ -173,12 +189,12 @@ function paquet_finElement($phraseur, $name) { $texte = trim($phraseur->versions[$n]['']); $phraseur->versions[$n][''] = ''; - $f = 'info_paquet_'.$name; - if (function_exists($f)) + $f = 'info_paquet_' . $name; + if (function_exists($f)) { $f($phraseur, $attrs, $texte); - elseif (!$attrs) + } elseif (!$attrs) { $phraseur->versions[$n][$name] = $texte; - else { + } else { // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; # echo("
pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); @@ -195,10 +211,11 @@ function paquet_finElement($phraseur, $name) { * @param string $texte */ function info_paquet_licence($phraseur, $attrs, $texte) { - if (isset($attrs['lien'])) + if (isset($attrs['lien'])) { $lien = $attrs['lien']; - else + } else { $lien = ''; + } $n = $phraseur->contenu['compatible']; $phraseur->versions[$n]['licence'][] = array('nom' => $texte, 'url' => $lien); } @@ -213,11 +230,12 @@ function info_paquet_licence($phraseur, $attrs, $texte) { */ function info_paquet_chemin($phraseur, $attrs, $texte) { $n = $phraseur->contenu['compatible']; - if (isset($attrs['path'])){ - if (isset($attrs['type'])) + if (isset($attrs['path'])) { + if (isset($attrs['type'])) { $phraseur->versions[$n]['chemin'][] = array('path' => $attrs['path'], 'type' => $attrs['type']); - else + } else { $phraseur->versions[$n]['chemin'][] = array('path' => $attrs['path']); + } } } @@ -233,18 +251,20 @@ function info_paquet_chemin($phraseur, $attrs, $texte) { */ function info_paquet_auteur($phraseur, $attrs, $texte) { # echo 'auteur ', $texte; var_dump($attrs); - if (isset($attrs['mail'])){ - if (strpos($attrs['mail'], '@')) + if (isset($attrs['mail'])) { + if (strpos($attrs['mail'], '@')) { $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']); + } $mail = $attrs['mail']; - } - else + } else { $mail = ''; + } - if (isset($attrs['lien'])) + if (isset($attrs['lien'])) { $lien = $attrs['lien']; - else + } else { $lien = ''; + } $n = $phraseur->contenu['compatible']; $phraseur->versions[$n]['auteur'][] = array('nom' => $texte, 'url' => $lien, 'mail' => $mail); @@ -260,10 +280,11 @@ function info_paquet_auteur($phraseur, $attrs, $texte) { */ function info_paquet_credit($phraseur, $attrs, $texte) { - if (isset($attrs['lien'])) + if (isset($attrs['lien'])) { $lien = $attrs['lien']; - else + } else { $lien = ''; + } $n = $phraseur->contenu['compatible']; $phraseur->versions[$n]['credit'][] = array('nom' => $texte, 'url' => $lien); @@ -298,12 +319,12 @@ function info_paquet_paquet($phraseur, $attrs, $texte) { /** * Cas particulier sur la balise traduire : - * Elle n'a pas de 'nom' + * Elle n'a pas de 'nom' * * @param object $phraseur * @param array $attrs * @param string $texte -**/ + **/ function info_paquet_traduire($phraseur, $attrs, $texte) { $n = $phraseur->contenu['compatible']; $phraseur->versions[$n]['traduire'][] = $attrs; @@ -326,13 +347,78 @@ function info_paquet_spip($phraseur, $attrs, $texte) { /** * Pipelines : plusieurs declarations possibles pour un meme pipeline * - * @param $phraseur - * @param $attrs - * @param $texte + * @param object $phraseur + * @param array $attrs + * @param string $texte */ function info_paquet_pipeline($phraseur, $attrs, $texte) { $n = $phraseur->contenu['compatible']; $phraseur->versions[$n]['pipeline'][] = $attrs; } -?> + +/** + * Style : plusieurs declarations possibles. + * Traitement de l'attribut source pour générer en remplacement les attributs url et path + * + * @param object $phraseur + * @param array $attrs + * @param string $texte + */ +function info_paquet_style($phraseur, $attrs, $texte) { + $lien = $chemin = $type = $media = ''; + + include_spip('inc/utils'); + if (tester_url_absolue($attrs['source'])) { + $lien = $attrs['source']; + } else { + $chemin = $attrs['source']; + } + if (isset($attrs['type'])) { + $type = $attrs['type']; + } + if (isset($attrs['media'])) { + $media = $attrs['media']; + } + + $n = $phraseur->contenu['compatible']; + $phraseur->versions[$n]['style'][] = array('url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media); +} + + +/** + * Script : plusieurs declarations possibles. + * Traitement de l'attribut source pour générer en remplacement les attributs url et path + * + * @param object $phraseur + * @param array $attrs + * @param string $texte + */ +function info_paquet_script($phraseur, $attrs, $texte) { + $lien = $chemin = $type = $media = ''; + + include_spip('inc/utils'); + if (tester_url_absolue($attrs['source'])) { + $lien = $attrs['source']; + } else { + $chemin = $attrs['source']; + } + if (isset($attrs['type'])) { + $type = $attrs['type']; + } + + $n = $phraseur->contenu['compatible']; + $phraseur->versions[$n]['script'][] = array('url' => $lien, 'path' => $chemin, 'type' => $type); +} + +/** + * Genie : plusieurs declarations possibles pour les crons + * + * @param object $phraseur + * @param array $attrs + * @param string $texte + */ +function info_paquet_genie($phraseur, $attrs, $texte) { + $n = $phraseur->contenu['compatible']; + $phraseur->versions[$n]['genie'][] = $attrs; +}